#
# MLDB-1624-more-join-test.py
# 2016-05-17
# This file is part of MLDB. Copyright 2016 mldb.ai inc. All rights reserved.
#


import unittest
import json
import random
from operator import itemgetter

mldb = mldb_wrapper.wrap(mldb) # noqa

# these tests are based on those found in the postgresql test suite
# https://github.com/postgres/postgres/blob/master/src/test/regress/expected/join.out

def pprint(resp):
    print(resp[0]),
    for row in resp[1:]:
        print(',')
        print(row),
    print('\n====================')
    headers = resp[0]
    print(headers),
    for row in sorted(resp[1:], key=itemgetter(0)):
        print(',')
        print(row),
    print('\n')


class JoinTest(MldbUnitTest):

    @classmethod
    def setUpClass(self):
        # create a dummy dataset
        ds = mldb.create_dataset({ "id": "J1_TBL", "type": "sparse.mutable" })
        ds.record_row("01",[["i", 1, 0], ["j", 4, 0], ["t", 'one', 0]])
        ds.record_row("02",[["i", 2, 0], ["j", 3, 0], ["t", 'two', 0]])
        ds.record_row("03",[["i", 3, 0], ["j", 2, 0], ["t", 'three', 0]])
        ds.record_row("04",[["i", 4, 0], ["j", 1, 0], ["t", 'four', 0]])
        ds.record_row("05",[["i", 5, 0], ["j", 0, 0], ["t", 'five', 0]])
        ds.record_row("06",[["i", 6, 0], ["j", 6, 0], ["t", 'six', 0]])
        ds.record_row("07",[["i", 7, 0], ["j", 7, 0], ["t", 'seven', 0]])
        ds.record_row("08",[["i", 8, 0], ["j", 8, 0], ["t", 'eight', 0]])
        ds.record_row("09",[["i", 0, 0], ["t", 'zero', 0]])
        ds.record_row("10",[["t", 'null', 0]])
        ds.record_row("11",[["j", 0, 0], ["t", 'zero', 0]])
        ds.commit()

        ds = mldb.create_dataset({ "id": "J2_TBL", "type": "tabular" })
        ds.record_row("01",[["i", 1, 0], ["k", -1, 0]])
        ds.record_row("02",[["i", 2, 0], ["k",  2, 0]])
        ds.record_row("03",[["i", 3, 0], ["k", -3, 0]])
        ds.record_row("04",[["i", 2, 0], ["k",  4, 0]])
        ds.record_row("05",[["i", 5, 0], ["k", -5, 0]])
        ds.record_row("06",[["i", 5, 0], ["k", -5, 0]])
        ds.record_row("07",[["i", 0, 0]])
        ds.record_row("08",[])
        ds.record_row("09",[["k", 0, 0]])
        ds.commit()

        ds = mldb.create_dataset({ "id": "t1", "type": "tabular" })
        ds.record_row("01",[["name", 'bb', 0], ["n", 11, 0]])
        ds.commit()

        ds = mldb.create_dataset({ "id": "t2", "type": "tabular" })
        ds.record_row("01",[["name", 'bb', 0], ["n", 12, 0]])
        ds.record_row("02",[["name", 'cc', 0], ["n", 22, 0]])
        ds.record_row("03",[["name", 'ee', 0], ["n", 42, 0]])
        ds.commit()

        ds = mldb.create_dataset({ "id": "t3", "type": "tabular" })
        ds.record_row("01",[["name", 'bb', 0], ["n", 13, 0]])
        ds.record_row("02",[["name", 'cc', 0], ["n", 23, 0]])
        ds.record_row("03",[["name", 'dd', 0], ["n", 33, 0]])
        ds.commit()

        ds = mldb.create_dataset({ "id": "x", "type": "tabular" })
        ds.record_row("01",[["x1", 1, 0], ["x2", 11, 0]])
        ds.record_row("02",[["x1", 2, 0], ["x2", 22, 0]])
        ds.record_row("03",[["x1", 3, 0]])
        ds.record_row("04",[["x1", 4, 0], ["x2", 44, 0]])
        ds.record_row("05",[["x1", 5, 0]])
        ds.commit()

        ds = mldb.create_dataset({ "id": "y", "type": "tabular" })
        ds.record_row("01",[["y1", 1, 0], ["y2", 111, 0]])
        ds.record_row("02",[["y1", 2, 0], ["y2", 222, 0]])
        ds.record_row("03",[["y1", 3, 0], ["y2", 333, 0]])
        ds.record_row("04",[["y1", 4, 0]])
        ds.commit()

        ds = mldb.create_dataset({ "id": "z", "type": "tabular" })
        ds.record_row("01",[["z1", 1, 0], ["z2", 11, 0]])
        ds.record_row("02",[["z1", 2, 0], ["z2", 22, 0]])
        ds.record_row("03",[["z1", 3, 0], ["z2", 33, 0]])
        ds.commit()


    def test_table_as(self):
        res = mldb.query("""
            SELECT '' AS "xxx", * FROM J1_TBL AS tx ORDER BY rowName()
        """)
        pprint(res)
        self.assertTableResultEquals(res,
            [
                [u'_rowName', u'i', u'j', u't', u'xxx'] ,
                [u'01', 1, 4, u'one', u''] ,
                [u'02', 2, 3, u'two', u''] ,
                [u'03', 3, 2, u'three', u''] ,
                [u'04', 4, 1, u'four', u''] ,
                [u'05', 5, 0, u'five', u''] ,
                [u'06', 6, 6, u'six', u''] ,
                [u'07', 7, 7, u'seven', u''] ,
                [u'08', 8, 8, u'eight', u''] ,
                [u'09', 0, None, u'zero', u''] ,
                [u'10', None, None, u'null', u''] ,
                [u'11', None, 0, u'zero', u'']
            ]
        )

    # CROSS JOIN is an INNER JOIN with the ON condition True
    def test_cross_join(self):
        res = mldb.query("""
            SELECT '' AS "xxx", * FROM J1_TBL INNER JOIN J2_TBL
        """)

        self.assertTableResultEquals(res,
            [
                [u'_rowName', u'J1_TBL.i', u'J1_TBL.j', u'J1_TBL.t', u'J2_TBL.i', u'J2_TBL.k', u'xxx'] ,
                [u'[01]-[01]', 1, 4, u'one', 1, -1, u''] ,
                [u'[01]-[02]', 1, 4, u'one', 2, 2, u''] ,
                [u'[01]-[03]', 1, 4, u'one', 3, -3, u''] ,
                [u'[01]-[04]', 1, 4, u'one', 2, 4, u''] ,
                [u'[01]-[05]', 1, 4, u'one', 5, -5, u''] ,
                [u'[01]-[06]', 1, 4, u'one', 5, -5, u''] ,
                [u'[01]-[07]', 1, 4, u'one', 0, None, u''] ,
                [u'[01]-[08]', 1, 4, u'one', None, None, u''] ,
                [u'[01]-[09]', 1, 4, u'one', None, 0, u''] ,
                [u'[02]-[01]', 2, 3, u'two', 1, -1, u''] ,
                [u'[02]-[02]', 2, 3, u'two', 2, 2, u''] ,
                [u'[02]-[03]', 2, 3, u'two', 3, -3, u''] ,
                [u'[02]-[04]', 2, 3, u'two', 2, 4, u''] ,
                [u'[02]-[05]', 2, 3, u'two', 5, -5, u''] ,
                [u'[02]-[06]', 2, 3, u'two', 5, -5, u''] ,
                [u'[02]-[07]', 2, 3, u'two', 0, None, u''] ,
                [u'[02]-[08]', 2, 3, u'two', None, None, u''] ,
                [u'[02]-[09]', 2, 3, u'two', None, 0, u''] ,
                [u'[03]-[01]', 3, 2, u'three', 1, -1, u''] ,
                [u'[03]-[02]', 3, 2, u'three', 2, 2, u''] ,
                [u'[03]-[03]', 3, 2, u'three', 3, -3, u''] ,
                [u'[03]-[04]', 3, 2, u'three', 2, 4, u''] ,
                [u'[03]-[05]', 3, 2, u'three', 5, -5, u''] ,
                [u'[03]-[06]', 3, 2, u'three', 5, -5, u''] ,
                [u'[03]-[07]', 3, 2, u'three', 0, None, u''] ,
                [u'[03]-[08]', 3, 2, u'three', None, None, u''] ,
                [u'[03]-[09]', 3, 2, u'three', None, 0, u''] ,
                [u'[04]-[01]', 4, 1, u'four', 1, -1, u''] ,
                [u'[04]-[02]', 4, 1, u'four', 2, 2, u''] ,
                [u'[04]-[03]', 4, 1, u'four', 3, -3, u''] ,
                [u'[04]-[04]', 4, 1, u'four', 2, 4, u''] ,
                [u'[04]-[05]', 4, 1, u'four', 5, -5, u''] ,
                [u'[04]-[06]', 4, 1, u'four', 5, -5, u''] ,
                [u'[04]-[07]', 4, 1, u'four', 0, None, u''] ,
                [u'[04]-[08]', 4, 1, u'four', None, None, u''] ,
                [u'[04]-[09]', 4, 1, u'four', None, 0, u''] ,
                [u'[05]-[01]', 5, 0, u'five', 1, -1, u''] ,
                [u'[05]-[02]', 5, 0, u'five', 2, 2, u''] ,
                [u'[05]-[03]', 5, 0, u'five', 3, -3, u''] ,
                [u'[05]-[04]', 5, 0, u'five', 2, 4, u''] ,
                [u'[05]-[05]', 5, 0, u'five', 5, -5, u''] ,
                [u'[05]-[06]', 5, 0, u'five', 5, -5, u''] ,
                [u'[05]-[07]', 5, 0, u'five', 0, None, u''] ,
                [u'[05]-[08]', 5, 0, u'five', None, None, u''] ,
                [u'[05]-[09]', 5, 0, u'five', None, 0, u''] ,
                [u'[06]-[01]', 6, 6, u'six', 1, -1, u''] ,
                [u'[06]-[02]', 6, 6, u'six', 2, 2, u''] ,
                [u'[06]-[03]', 6, 6, u'six', 3, -3, u''] ,
                [u'[06]-[04]', 6, 6, u'six', 2, 4, u''] ,
                [u'[06]-[05]', 6, 6, u'six', 5, -5, u''] ,
                [u'[06]-[06]', 6, 6, u'six', 5, -5, u''] ,
                [u'[06]-[07]', 6, 6, u'six', 0, None, u''] ,
                [u'[06]-[08]', 6, 6, u'six', None, None, u''] ,
                [u'[06]-[09]', 6, 6, u'six', None, 0, u''] ,
                [u'[07]-[01]', 7, 7, u'seven', 1, -1, u''] ,
                [u'[07]-[02]', 7, 7, u'seven', 2, 2, u''] ,
                [u'[07]-[03]', 7, 7, u'seven', 3, -3, u''] ,
                [u'[07]-[04]', 7, 7, u'seven', 2, 4, u''] ,
                [u'[07]-[05]', 7, 7, u'seven', 5, -5, u''] ,
                [u'[07]-[06]', 7, 7, u'seven', 5, -5, u''] ,
                [u'[07]-[07]', 7, 7, u'seven', 0, None, u''] ,
                [u'[07]-[08]', 7, 7, u'seven', None, None, u''] ,
                [u'[07]-[09]', 7, 7, u'seven', None, 0, u''] ,
                [u'[08]-[01]', 8, 8, u'eight', 1, -1, u''] ,
                [u'[08]-[02]', 8, 8, u'eight', 2, 2, u''] ,
                [u'[08]-[03]', 8, 8, u'eight', 3, -3, u''] ,
                [u'[08]-[04]', 8, 8, u'eight', 2, 4, u''] ,
                [u'[08]-[05]', 8, 8, u'eight', 5, -5, u''] ,
                [u'[08]-[06]', 8, 8, u'eight', 5, -5, u''] ,
                [u'[08]-[07]', 8, 8, u'eight', 0, None, u''] ,
                [u'[08]-[08]', 8, 8, u'eight', None, None, u''] ,
                [u'[08]-[09]', 8, 8, u'eight', None, 0, u''] ,
                [u'[09]-[01]', 0, None, u'zero', 1, -1, u''] ,
                [u'[09]-[02]', 0, None, u'zero', 2, 2, u''] ,
                [u'[09]-[03]', 0, None, u'zero', 3, -3, u''] ,
                [u'[09]-[04]', 0, None, u'zero', 2, 4, u''] ,
                [u'[09]-[05]', 0, None, u'zero', 5, -5, u''] ,
                [u'[09]-[06]', 0, None, u'zero', 5, -5, u''] ,
                [u'[09]-[07]', 0, None, u'zero', 0, None, u''] ,
                [u'[09]-[08]', 0, None, u'zero', None, None, u''] ,
                [u'[09]-[09]', 0, None, u'zero', None, 0, u''] ,
                [u'[10]-[01]', None, None, u'null', 1, -1, u''] ,
                [u'[10]-[02]', None, None, u'null', 2, 2, u''] ,
                [u'[10]-[03]', None, None, u'null', 3, -3, u''] ,
                [u'[10]-[04]', None, None, u'null', 2, 4, u''] ,
                [u'[10]-[05]', None, None, u'null', 5, -5, u''] ,
                [u'[10]-[06]', None, None, u'null', 5, -5, u''] ,
                [u'[10]-[07]', None, None, u'null', 0, None, u''] ,
                [u'[10]-[08]', None, None, u'null', None, None, u''] ,
                [u'[10]-[09]', None, None, u'null', None, 0, u''] ,
                [u'[11]-[01]', None, 0, u'zero', 1, -1, u''] ,
                [u'[11]-[02]', None, 0, u'zero', 2, 2, u''] ,
                [u'[11]-[03]', None, 0, u'zero', 3, -3, u''] ,
                [u'[11]-[04]', None, 0, u'zero', 2, 4, u''] ,
                [u'[11]-[05]', None, 0, u'zero', 5, -5, u''] ,
                [u'[11]-[06]', None, 0, u'zero', 5, -5, u''] ,
                [u'[11]-[07]', None, 0, u'zero', 0, None, u''] ,
                [u'[11]-[08]', None, 0, u'zero', None, None, u''] ,
                [u'[11]-[09]', None, 0, u'zero', None, 0, u'']
            ]
        )

        res = mldb.query("""
            SELECT '' AS "xxx", t1.i, t2.k, t1.t FROM J1_TBL AS t1 INNER JOIN J2_TBL AS t2
        """)

        self.assertTableResultEquals(res,
            [
                [u'_rowName', u't1.i', u't1.t', u't2.k', u'xxx'] ,
                [u'[01]-[01]', 1, u'one', -1, u''] ,
                [u'[01]-[02]', 1, u'one', 2, u''] ,
                [u'[01]-[03]', 1, u'one', -3, u''] ,
                [u'[01]-[04]', 1, u'one', 4, u''] ,
                [u'[01]-[05]', 1, u'one', -5, u''] ,
                [u'[01]-[06]', 1, u'one', -5, u''] ,
                [u'[01]-[07]', 1, u'one', None, u''] ,
                [u'[01]-[08]', 1, u'one', None, u''] ,
                [u'[01]-[09]', 1, u'one', 0, u''] ,
                [u'[02]-[01]', 2, u'two', -1, u''] ,
                [u'[02]-[02]', 2, u'two', 2, u''] ,
                [u'[02]-[03]', 2, u'two', -3, u''] ,
                [u'[02]-[04]', 2, u'two', 4, u''] ,
                [u'[02]-[05]', 2, u'two', -5, u''] ,
                [u'[02]-[06]', 2, u'two', -5, u''] ,
                [u'[02]-[07]', 2, u'two', None, u''] ,
                [u'[02]-[08]', 2, u'two', None, u''] ,
                [u'[02]-[09]', 2, u'two', 0, u''] ,
                [u'[03]-[01]', 3, u'three', -1, u''] ,
                [u'[03]-[02]', 3, u'three', 2, u''] ,
                [u'[03]-[03]', 3, u'three', -3, u''] ,
                [u'[03]-[04]', 3, u'three', 4, u''] ,
                [u'[03]-[05]', 3, u'three', -5, u''] ,
                [u'[03]-[06]', 3, u'three', -5, u''] ,
                [u'[03]-[07]', 3, u'three', None, u''] ,
                [u'[03]-[08]', 3, u'three', None, u''] ,
                [u'[03]-[09]', 3, u'three', 0, u''] ,
                [u'[04]-[01]', 4, u'four', -1, u''] ,
                [u'[04]-[02]', 4, u'four', 2, u''] ,
                [u'[04]-[03]', 4, u'four', -3, u''] ,
                [u'[04]-[04]', 4, u'four', 4, u''] ,
                [u'[04]-[05]', 4, u'four', -5, u''] ,
                [u'[04]-[06]', 4, u'four', -5, u''] ,
                [u'[04]-[07]', 4, u'four', None, u''] ,
                [u'[04]-[08]', 4, u'four', None, u''] ,
                [u'[04]-[09]', 4, u'four', 0, u''] ,
                [u'[05]-[01]', 5, u'five', -1, u''] ,
                [u'[05]-[02]', 5, u'five', 2, u''] ,
                [u'[05]-[03]', 5, u'five', -3, u''] ,
                [u'[05]-[04]', 5, u'five', 4, u''] ,
                [u'[05]-[05]', 5, u'five', -5, u''] ,
                [u'[05]-[06]', 5, u'five', -5, u''] ,
                [u'[05]-[07]', 5, u'five', None, u''] ,
                [u'[05]-[08]', 5, u'five', None, u''] ,
                [u'[05]-[09]', 5, u'five', 0, u''] ,
                [u'[06]-[01]', 6, u'six', -1, u''] ,
                [u'[06]-[02]', 6, u'six', 2, u''] ,
                [u'[06]-[03]', 6, u'six', -3, u''] ,
                [u'[06]-[04]', 6, u'six', 4, u''] ,
                [u'[06]-[05]', 6, u'six', -5, u''] ,
                [u'[06]-[06]', 6, u'six', -5, u''] ,
                [u'[06]-[07]', 6, u'six', None, u''] ,
                [u'[06]-[08]', 6, u'six', None, u''] ,
                [u'[06]-[09]', 6, u'six', 0, u''] ,
                [u'[07]-[01]', 7, u'seven', -1, u''] ,
                [u'[07]-[02]', 7, u'seven', 2, u''] ,
                [u'[07]-[03]', 7, u'seven', -3, u''] ,
                [u'[07]-[04]', 7, u'seven', 4, u''] ,
                [u'[07]-[05]', 7, u'seven', -5, u''] ,
                [u'[07]-[06]', 7, u'seven', -5, u''] ,
                [u'[07]-[07]', 7, u'seven', None, u''] ,
                [u'[07]-[08]', 7, u'seven', None, u''] ,
                [u'[07]-[09]', 7, u'seven', 0, u''] ,
                [u'[08]-[01]', 8, u'eight', -1, u''] ,
                [u'[08]-[02]', 8, u'eight', 2, u''] ,
                [u'[08]-[03]', 8, u'eight', -3, u''] ,
                [u'[08]-[04]', 8, u'eight', 4, u''] ,
                [u'[08]-[05]', 8, u'eight', -5, u''] ,
                [u'[08]-[06]', 8, u'eight', -5, u''] ,
                [u'[08]-[07]', 8, u'eight', None, u''] ,
                [u'[08]-[08]', 8, u'eight', None, u''] ,
                [u'[08]-[09]', 8, u'eight', 0, u''] ,
                [u'[09]-[01]', 0, u'zero', -1, u''] ,
                [u'[09]-[02]', 0, u'zero', 2, u''] ,
                [u'[09]-[03]', 0, u'zero', -3, u''] ,
                [u'[09]-[04]', 0, u'zero', 4, u''] ,
                [u'[09]-[05]', 0, u'zero', -5, u''] ,
                [u'[09]-[06]', 0, u'zero', -5, u''] ,
                [u'[09]-[07]', 0, u'zero', None, u''] ,
                [u'[09]-[08]', 0, u'zero', None, u''] ,
                [u'[09]-[09]', 0, u'zero', 0, u''] ,
                [u'[10]-[01]', None, u'null', -1, u''] ,
                [u'[10]-[02]', None, u'null', 2, u''] ,
                [u'[10]-[03]', None, u'null', -3, u''] ,
                [u'[10]-[04]', None, u'null', 4, u''] ,
                [u'[10]-[05]', None, u'null', -5, u''] ,
                [u'[10]-[06]', None, u'null', -5, u''] ,
                [u'[10]-[07]', None, u'null', None, u''] ,
                [u'[10]-[08]', None, u'null', None, u''] ,
                [u'[10]-[09]', None, u'null', 0, u''] ,
                [u'[11]-[01]', None, u'zero', -1, u''] ,
                [u'[11]-[02]', None, u'zero', 2, u''] ,
                [u'[11]-[03]', None, u'zero', -3, u''] ,
                [u'[11]-[04]', None, u'zero', 4, u''] ,
                [u'[11]-[05]', None, u'zero', -5, u''] ,
                [u'[11]-[06]', None, u'zero', -5, u''] ,
                [u'[11]-[07]', None, u'zero', None, u''] ,
                [u'[11]-[08]', None, u'zero', None, u''] ,
                [u'[11]-[09]', None, u'zero', 0, u'']
            ]
        )

        res = mldb.query("""
            SELECT '' AS "xxx", * FROM J1_TBL INNER JOIN J2_TBL AS a INNER JOIN J2_TBL AS b
        """)

        self.assertTableResultEquals(res,
            [
                [u'_rowName', u'J1_TBL.i', u'J1_TBL.j', u'J1_TBL.t', u'a.i', u'a.k', u'b.i', u'b.k', u'xxx'] ,
                [u'[01]-[[01]-[01]]', 1, 4, u'one', 1, -1, 1, -1, u''] ,
                [u'[01]-[[01]-[02]]', 1, 4, u'one', 1, -1, 2, 2, u''] ,
                [u'[01]-[[01]-[03]]', 1, 4, u'one', 1, -1, 3, -3, u''] ,
                [u'[01]-[[01]-[04]]', 1, 4, u'one', 1, -1, 2, 4, u''] ,
                [u'[01]-[[01]-[05]]', 1, 4, u'one', 1, -1, 5, -5, u''] ,
                [u'[01]-[[01]-[06]]', 1, 4, u'one', 1, -1, 5, -5, u''] ,
                [u'[01]-[[01]-[07]]', 1, 4, u'one', 1, -1, 0, None, u''] ,
                [u'[01]-[[01]-[08]]', 1, 4, u'one', 1, -1, None, None, u''] ,
                [u'[01]-[[01]-[09]]', 1, 4, u'one', 1, -1, None, 0, u''] ,
                [u'[01]-[[02]-[01]]', 1, 4, u'one', 2, 2, 1, -1, u''] ,
                [u'[01]-[[02]-[02]]', 1, 4, u'one', 2, 2, 2, 2, u''] ,
                [u'[01]-[[02]-[03]]', 1, 4, u'one', 2, 2, 3, -3, u''] ,
                [u'[01]-[[02]-[04]]', 1, 4, u'one', 2, 2, 2, 4, u''] ,
                [u'[01]-[[02]-[05]]', 1, 4, u'one', 2, 2, 5, -5, u''] ,
                [u'[01]-[[02]-[06]]', 1, 4, u'one', 2, 2, 5, -5, u''] ,
                [u'[01]-[[02]-[07]]', 1, 4, u'one', 2, 2, 0, None, u''] ,
                [u'[01]-[[02]-[08]]', 1, 4, u'one', 2, 2, None, None, u''] ,
                [u'[01]-[[02]-[09]]', 1, 4, u'one', 2, 2, None, 0, u''] ,
                [u'[01]-[[03]-[01]]', 1, 4, u'one', 3, -3, 1, -1, u''] ,
                [u'[01]-[[03]-[02]]', 1, 4, u'one', 3, -3, 2, 2, u''] ,
                [u'[01]-[[03]-[03]]', 1, 4, u'one', 3, -3, 3, -3, u''] ,
                [u'[01]-[[03]-[04]]', 1, 4, u'one', 3, -3, 2, 4, u''] ,
                [u'[01]-[[03]-[05]]', 1, 4, u'one', 3, -3, 5, -5, u''] ,
                [u'[01]-[[03]-[06]]', 1, 4, u'one', 3, -3, 5, -5, u''] ,
                [u'[01]-[[03]-[07]]', 1, 4, u'one', 3, -3, 0, None, u''] ,
                [u'[01]-[[03]-[08]]', 1, 4, u'one', 3, -3, None, None, u''] ,
                [u'[01]-[[03]-[09]]', 1, 4, u'one', 3, -3, None, 0, u''] ,
                [u'[01]-[[04]-[01]]', 1, 4, u'one', 2, 4, 1, -1, u''] ,
                [u'[01]-[[04]-[02]]', 1, 4, u'one', 2, 4, 2, 2, u''] ,
                [u'[01]-[[04]-[03]]', 1, 4, u'one', 2, 4, 3, -3, u''] ,
                [u'[01]-[[04]-[04]]', 1, 4, u'one', 2, 4, 2, 4, u''] ,
                [u'[01]-[[04]-[05]]', 1, 4, u'one', 2, 4, 5, -5, u''] ,
                [u'[01]-[[04]-[06]]', 1, 4, u'one', 2, 4, 5, -5, u''] ,
                [u'[01]-[[04]-[07]]', 1, 4, u'one', 2, 4, 0, None, u''] ,
                [u'[01]-[[04]-[08]]', 1, 4, u'one', 2, 4, None, None, u''] ,
                [u'[01]-[[04]-[09]]', 1, 4, u'one', 2, 4, None, 0, u''] ,
                [u'[01]-[[05]-[01]]', 1, 4, u'one', 5, -5, 1, -1, u''] ,
                [u'[01]-[[05]-[02]]', 1, 4, u'one', 5, -5, 2, 2, u''] ,
                [u'[01]-[[05]-[03]]', 1, 4, u'one', 5, -5, 3, -3, u''] ,
                [u'[01]-[[05]-[04]]', 1, 4, u'one', 5, -5, 2, 4, u''] ,
                [u'[01]-[[05]-[05]]', 1, 4, u'one', 5, -5, 5, -5, u''] ,
                [u'[01]-[[05]-[06]]', 1, 4, u'one', 5, -5, 5, -5, u''] ,
                [u'[01]-[[05]-[07]]', 1, 4, u'one', 5, -5, 0, None, u''] ,
                [u'[01]-[[05]-[08]]', 1, 4, u'one', 5, -5, None, None, u''] ,
                [u'[01]-[[05]-[09]]', 1, 4, u'one', 5, -5, None, 0, u''] ,
                [u'[01]-[[06]-[01]]', 1, 4, u'one', 5, -5, 1, -1, u''] ,
                [u'[01]-[[06]-[02]]', 1, 4, u'one', 5, -5, 2, 2, u''] ,
                [u'[01]-[[06]-[03]]', 1, 4, u'one', 5, -5, 3, -3, u''] ,
                [u'[01]-[[06]-[04]]', 1, 4, u'one', 5, -5, 2, 4, u''] ,
                [u'[01]-[[06]-[05]]', 1, 4, u'one', 5, -5, 5, -5, u''] ,
                [u'[01]-[[06]-[06]]', 1, 4, u'one', 5, -5, 5, -5, u''] ,
                [u'[01]-[[06]-[07]]', 1, 4, u'one', 5, -5, 0, None, u''] ,
                [u'[01]-[[06]-[08]]', 1, 4, u'one', 5, -5, None, None, u''] ,
                [u'[01]-[[06]-[09]]', 1, 4, u'one', 5, -5, None, 0, u''] ,
                [u'[01]-[[07]-[01]]', 1, 4, u'one', 0, None, 1, -1, u''] ,
                [u'[01]-[[07]-[02]]', 1, 4, u'one', 0, None, 2, 2, u''] ,
                [u'[01]-[[07]-[03]]', 1, 4, u'one', 0, None, 3, -3, u''] ,
                [u'[01]-[[07]-[04]]', 1, 4, u'one', 0, None, 2, 4, u''] ,
                [u'[01]-[[07]-[05]]', 1, 4, u'one', 0, None, 5, -5, u''] ,
                [u'[01]-[[07]-[06]]', 1, 4, u'one', 0, None, 5, -5, u''] ,
                [u'[01]-[[07]-[07]]', 1, 4, u'one', 0, None, 0, None, u''] ,
                [u'[01]-[[07]-[08]]', 1, 4, u'one', 0, None, None, None, u''] ,
                [u'[01]-[[07]-[09]]', 1, 4, u'one', 0, None, None, 0, u''] ,
                [u'[01]-[[08]-[01]]', 1, 4, u'one', None, None, 1, -1, u''] ,
                [u'[01]-[[08]-[02]]', 1, 4, u'one', None, None, 2, 2, u''] ,
                [u'[01]-[[08]-[03]]', 1, 4, u'one', None, None, 3, -3, u''] ,
                [u'[01]-[[08]-[04]]', 1, 4, u'one', None, None, 2, 4, u''] ,
                [u'[01]-[[08]-[05]]', 1, 4, u'one', None, None, 5, -5, u''] ,
                [u'[01]-[[08]-[06]]', 1, 4, u'one', None, None, 5, -5, u''] ,
                [u'[01]-[[08]-[07]]', 1, 4, u'one', None, None, 0, None, u''] ,
                [u'[01]-[[08]-[08]]', 1, 4, u'one', None, None, None, None, u''] ,
                [u'[01]-[[08]-[09]]', 1, 4, u'one', None, None, None, 0, u''] ,
                [u'[01]-[[09]-[01]]', 1, 4, u'one', None, 0, 1, -1, u''] ,
                [u'[01]-[[09]-[02]]', 1, 4, u'one', None, 0, 2, 2, u''] ,
                [u'[01]-[[09]-[03]]', 1, 4, u'one', None, 0, 3, -3, u''] ,
                [u'[01]-[[09]-[04]]', 1, 4, u'one', None, 0, 2, 4, u''] ,
                [u'[01]-[[09]-[05]]', 1, 4, u'one', None, 0, 5, -5, u''] ,
                [u'[01]-[[09]-[06]]', 1, 4, u'one', None, 0, 5, -5, u''] ,
                [u'[01]-[[09]-[07]]', 1, 4, u'one', None, 0, 0, None, u''] ,
                [u'[01]-[[09]-[08]]', 1, 4, u'one', None, 0, None, None, u''] ,
                [u'[01]-[[09]-[09]]', 1, 4, u'one', None, 0, None, 0, u''] ,
                [u'[02]-[[01]-[01]]', 2, 3, u'two', 1, -1, 1, -1, u''] ,
                [u'[02]-[[01]-[02]]', 2, 3, u'two', 1, -1, 2, 2, u''] ,
                [u'[02]-[[01]-[03]]', 2, 3, u'two', 1, -1, 3, -3, u''] ,
                [u'[02]-[[01]-[04]]', 2, 3, u'two', 1, -1, 2, 4, u''] ,
                [u'[02]-[[01]-[05]]', 2, 3, u'two', 1, -1, 5, -5, u''] ,
                [u'[02]-[[01]-[06]]', 2, 3, u'two', 1, -1, 5, -5, u''] ,
                [u'[02]-[[01]-[07]]', 2, 3, u'two', 1, -1, 0, None, u''] ,
                [u'[02]-[[01]-[08]]', 2, 3, u'two', 1, -1, None, None, u''] ,
                [u'[02]-[[01]-[09]]', 2, 3, u'two', 1, -1, None, 0, u''] ,
                [u'[02]-[[02]-[01]]', 2, 3, u'two', 2, 2, 1, -1, u''] ,
                [u'[02]-[[02]-[02]]', 2, 3, u'two', 2, 2, 2, 2, u''] ,
                [u'[02]-[[02]-[03]]', 2, 3, u'two', 2, 2, 3, -3, u''] ,
                [u'[02]-[[02]-[04]]', 2, 3, u'two', 2, 2, 2, 4, u''] ,
                [u'[02]-[[02]-[05]]', 2, 3, u'two', 2, 2, 5, -5, u''] ,
                [u'[02]-[[02]-[06]]', 2, 3, u'two', 2, 2, 5, -5, u''] ,
                [u'[02]-[[02]-[07]]', 2, 3, u'two', 2, 2, 0, None, u''] ,
                [u'[02]-[[02]-[08]]', 2, 3, u'two', 2, 2, None, None, u''] ,
                [u'[02]-[[02]-[09]]', 2, 3, u'two', 2, 2, None, 0, u''] ,
                [u'[02]-[[03]-[01]]', 2, 3, u'two', 3, -3, 1, -1, u''] ,
                [u'[02]-[[03]-[02]]', 2, 3, u'two', 3, -3, 2, 2, u''] ,
                [u'[02]-[[03]-[03]]', 2, 3, u'two', 3, -3, 3, -3, u''] ,
                [u'[02]-[[03]-[04]]', 2, 3, u'two', 3, -3, 2, 4, u''] ,
                [u'[02]-[[03]-[05]]', 2, 3, u'two', 3, -3, 5, -5, u''] ,
                [u'[02]-[[03]-[06]]', 2, 3, u'two', 3, -3, 5, -5, u''] ,
                [u'[02]-[[03]-[07]]', 2, 3, u'two', 3, -3, 0, None, u''] ,
                [u'[02]-[[03]-[08]]', 2, 3, u'two', 3, -3, None, None, u''] ,
                [u'[02]-[[03]-[09]]', 2, 3, u'two', 3, -3, None, 0, u''] ,
                [u'[02]-[[04]-[01]]', 2, 3, u'two', 2, 4, 1, -1, u''] ,
                [u'[02]-[[04]-[02]]', 2, 3, u'two', 2, 4, 2, 2, u''] ,
                [u'[02]-[[04]-[03]]', 2, 3, u'two', 2, 4, 3, -3, u''] ,
                [u'[02]-[[04]-[04]]', 2, 3, u'two', 2, 4, 2, 4, u''] ,
                [u'[02]-[[04]-[05]]', 2, 3, u'two', 2, 4, 5, -5, u''] ,
                [u'[02]-[[04]-[06]]', 2, 3, u'two', 2, 4, 5, -5, u''] ,
                [u'[02]-[[04]-[07]]', 2, 3, u'two', 2, 4, 0, None, u''] ,
                [u'[02]-[[04]-[08]]', 2, 3, u'two', 2, 4, None, None, u''] ,
                [u'[02]-[[04]-[09]]', 2, 3, u'two', 2, 4, None, 0, u''] ,
                [u'[02]-[[05]-[01]]', 2, 3, u'two', 5, -5, 1, -1, u''] ,
                [u'[02]-[[05]-[02]]', 2, 3, u'two', 5, -5, 2, 2, u''] ,
                [u'[02]-[[05]-[03]]', 2, 3, u'two', 5, -5, 3, -3, u''] ,
                [u'[02]-[[05]-[04]]', 2, 3, u'two', 5, -5, 2, 4, u''] ,
                [u'[02]-[[05]-[05]]', 2, 3, u'two', 5, -5, 5, -5, u''] ,
                [u'[02]-[[05]-[06]]', 2, 3, u'two', 5, -5, 5, -5, u''] ,
                [u'[02]-[[05]-[07]]', 2, 3, u'two', 5, -5, 0, None, u''] ,
                [u'[02]-[[05]-[08]]', 2, 3, u'two', 5, -5, None, None, u''] ,
                [u'[02]-[[05]-[09]]', 2, 3, u'two', 5, -5, None, 0, u''] ,
                [u'[02]-[[06]-[01]]', 2, 3, u'two', 5, -5, 1, -1, u''] ,
                [u'[02]-[[06]-[02]]', 2, 3, u'two', 5, -5, 2, 2, u''] ,
                [u'[02]-[[06]-[03]]', 2, 3, u'two', 5, -5, 3, -3, u''] ,
                [u'[02]-[[06]-[04]]', 2, 3, u'two', 5, -5, 2, 4, u''] ,
                [u'[02]-[[06]-[05]]', 2, 3, u'two', 5, -5, 5, -5, u''] ,
                [u'[02]-[[06]-[06]]', 2, 3, u'two', 5, -5, 5, -5, u''] ,
                [u'[02]-[[06]-[07]]', 2, 3, u'two', 5, -5, 0, None, u''] ,
                [u'[02]-[[06]-[08]]', 2, 3, u'two', 5, -5, None, None, u''] ,
                [u'[02]-[[06]-[09]]', 2, 3, u'two', 5, -5, None, 0, u''] ,
                [u'[02]-[[07]-[01]]', 2, 3, u'two', 0, None, 1, -1, u''] ,
                [u'[02]-[[07]-[02]]', 2, 3, u'two', 0, None, 2, 2, u''] ,
                [u'[02]-[[07]-[03]]', 2, 3, u'two', 0, None, 3, -3, u''] ,
                [u'[02]-[[07]-[04]]', 2, 3, u'two', 0, None, 2, 4, u''] ,
                [u'[02]-[[07]-[05]]', 2, 3, u'two', 0, None, 5, -5, u''] ,
                [u'[02]-[[07]-[06]]', 2, 3, u'two', 0, None, 5, -5, u''] ,
                [u'[02]-[[07]-[07]]', 2, 3, u'two', 0, None, 0, None, u''] ,
                [u'[02]-[[07]-[08]]', 2, 3, u'two', 0, None, None, None, u''] ,
                [u'[02]-[[07]-[09]]', 2, 3, u'two', 0, None, None, 0, u''] ,
                [u'[02]-[[08]-[01]]', 2, 3, u'two', None, None, 1, -1, u''] ,
                [u'[02]-[[08]-[02]]', 2, 3, u'two', None, None, 2, 2, u''] ,
                [u'[02]-[[08]-[03]]', 2, 3, u'two', None, None, 3, -3, u''] ,
                [u'[02]-[[08]-[04]]', 2, 3, u'two', None, None, 2, 4, u''] ,
                [u'[02]-[[08]-[05]]', 2, 3, u'two', None, None, 5, -5, u''] ,
                [u'[02]-[[08]-[06]]', 2, 3, u'two', None, None, 5, -5, u''] ,
                [u'[02]-[[08]-[07]]', 2, 3, u'two', None, None, 0, None, u''] ,
                [u'[02]-[[08]-[08]]', 2, 3, u'two', None, None, None, None, u''] ,
                [u'[02]-[[08]-[09]]', 2, 3, u'two', None, None, None, 0, u''] ,
                [u'[02]-[[09]-[01]]', 2, 3, u'two', None, 0, 1, -1, u''] ,
                [u'[02]-[[09]-[02]]', 2, 3, u'two', None, 0, 2, 2, u''] ,
                [u'[02]-[[09]-[03]]', 2, 3, u'two', None, 0, 3, -3, u''] ,
                [u'[02]-[[09]-[04]]', 2, 3, u'two', None, 0, 2, 4, u''] ,
                [u'[02]-[[09]-[05]]', 2, 3, u'two', None, 0, 5, -5, u''] ,
                [u'[02]-[[09]-[06]]', 2, 3, u'two', None, 0, 5, -5, u''] ,
                [u'[02]-[[09]-[07]]', 2, 3, u'two', None, 0, 0, None, u''] ,
                [u'[02]-[[09]-[08]]', 2, 3, u'two', None, 0, None, None, u''] ,
                [u'[02]-[[09]-[09]]', 2, 3, u'two', None, 0, None, 0, u''] ,
                [u'[03]-[[01]-[01]]', 3, 2, u'three', 1, -1, 1, -1, u''] ,
                [u'[03]-[[01]-[02]]', 3, 2, u'three', 1, -1, 2, 2, u''] ,
                [u'[03]-[[01]-[03]]', 3, 2, u'three', 1, -1, 3, -3, u''] ,
                [u'[03]-[[01]-[04]]', 3, 2, u'three', 1, -1, 2, 4, u''] ,
                [u'[03]-[[01]-[05]]', 3, 2, u'three', 1, -1, 5, -5, u''] ,
                [u'[03]-[[01]-[06]]', 3, 2, u'three', 1, -1, 5, -5, u''] ,
                [u'[03]-[[01]-[07]]', 3, 2, u'three', 1, -1, 0, None, u''] ,
                [u'[03]-[[01]-[08]]', 3, 2, u'three', 1, -1, None, None, u''] ,
                [u'[03]-[[01]-[09]]', 3, 2, u'three', 1, -1, None, 0, u''] ,
                [u'[03]-[[02]-[01]]', 3, 2, u'three', 2, 2, 1, -1, u''] ,
                [u'[03]-[[02]-[02]]', 3, 2, u'three', 2, 2, 2, 2, u''] ,
                [u'[03]-[[02]-[03]]', 3, 2, u'three', 2, 2, 3, -3, u''] ,
                [u'[03]-[[02]-[04]]', 3, 2, u'three', 2, 2, 2, 4, u''] ,
                [u'[03]-[[02]-[05]]', 3, 2, u'three', 2, 2, 5, -5, u''] ,
                [u'[03]-[[02]-[06]]', 3, 2, u'three', 2, 2, 5, -5, u''] ,
                [u'[03]-[[02]-[07]]', 3, 2, u'three', 2, 2, 0, None, u''] ,
                [u'[03]-[[02]-[08]]', 3, 2, u'three', 2, 2, None, None, u''] ,
                [u'[03]-[[02]-[09]]', 3, 2, u'three', 2, 2, None, 0, u''] ,
                [u'[03]-[[03]-[01]]', 3, 2, u'three', 3, -3, 1, -1, u''] ,
                [u'[03]-[[03]-[02]]', 3, 2, u'three', 3, -3, 2, 2, u''] ,
                [u'[03]-[[03]-[03]]', 3, 2, u'three', 3, -3, 3, -3, u''] ,
                [u'[03]-[[03]-[04]]', 3, 2, u'three', 3, -3, 2, 4, u''] ,
                [u'[03]-[[03]-[05]]', 3, 2, u'three', 3, -3, 5, -5, u''] ,
                [u'[03]-[[03]-[06]]', 3, 2, u'three', 3, -3, 5, -5, u''] ,
                [u'[03]-[[03]-[07]]', 3, 2, u'three', 3, -3, 0, None, u''] ,
                [u'[03]-[[03]-[08]]', 3, 2, u'three', 3, -3, None, None, u''] ,
                [u'[03]-[[03]-[09]]', 3, 2, u'three', 3, -3, None, 0, u''] ,
                [u'[03]-[[04]-[01]]', 3, 2, u'three', 2, 4, 1, -1, u''] ,
                [u'[03]-[[04]-[02]]', 3, 2, u'three', 2, 4, 2, 2, u''] ,
                [u'[03]-[[04]-[03]]', 3, 2, u'three', 2, 4, 3, -3, u''] ,
                [u'[03]-[[04]-[04]]', 3, 2, u'three', 2, 4, 2, 4, u''] ,
                [u'[03]-[[04]-[05]]', 3, 2, u'three', 2, 4, 5, -5, u''] ,
                [u'[03]-[[04]-[06]]', 3, 2, u'three', 2, 4, 5, -5, u''] ,
                [u'[03]-[[04]-[07]]', 3, 2, u'three', 2, 4, 0, None, u''] ,
                [u'[03]-[[04]-[08]]', 3, 2, u'three', 2, 4, None, None, u''] ,
                [u'[03]-[[04]-[09]]', 3, 2, u'three', 2, 4, None, 0, u''] ,
                [u'[03]-[[05]-[01]]', 3, 2, u'three', 5, -5, 1, -1, u''] ,
                [u'[03]-[[05]-[02]]', 3, 2, u'three', 5, -5, 2, 2, u''] ,
                [u'[03]-[[05]-[03]]', 3, 2, u'three', 5, -5, 3, -3, u''] ,
                [u'[03]-[[05]-[04]]', 3, 2, u'three', 5, -5, 2, 4, u''] ,
                [u'[03]-[[05]-[05]]', 3, 2, u'three', 5, -5, 5, -5, u''] ,
                [u'[03]-[[05]-[06]]', 3, 2, u'three', 5, -5, 5, -5, u''] ,
                [u'[03]-[[05]-[07]]', 3, 2, u'three', 5, -5, 0, None, u''] ,
                [u'[03]-[[05]-[08]]', 3, 2, u'three', 5, -5, None, None, u''] ,
                [u'[03]-[[05]-[09]]', 3, 2, u'three', 5, -5, None, 0, u''] ,
                [u'[03]-[[06]-[01]]', 3, 2, u'three', 5, -5, 1, -1, u''] ,
                [u'[03]-[[06]-[02]]', 3, 2, u'three', 5, -5, 2, 2, u''] ,
                [u'[03]-[[06]-[03]]', 3, 2, u'three', 5, -5, 3, -3, u''] ,
                [u'[03]-[[06]-[04]]', 3, 2, u'three', 5, -5, 2, 4, u''] ,
                [u'[03]-[[06]-[05]]', 3, 2, u'three', 5, -5, 5, -5, u''] ,
                [u'[03]-[[06]-[06]]', 3, 2, u'three', 5, -5, 5, -5, u''] ,
                [u'[03]-[[06]-[07]]', 3, 2, u'three', 5, -5, 0, None, u''] ,
                [u'[03]-[[06]-[08]]', 3, 2, u'three', 5, -5, None, None, u''] ,
                [u'[03]-[[06]-[09]]', 3, 2, u'three', 5, -5, None, 0, u''] ,
                [u'[03]-[[07]-[01]]', 3, 2, u'three', 0, None, 1, -1, u''] ,
                [u'[03]-[[07]-[02]]', 3, 2, u'three', 0, None, 2, 2, u''] ,
                [u'[03]-[[07]-[03]]', 3, 2, u'three', 0, None, 3, -3, u''] ,
                [u'[03]-[[07]-[04]]', 3, 2, u'three', 0, None, 2, 4, u''] ,
                [u'[03]-[[07]-[05]]', 3, 2, u'three', 0, None, 5, -5, u''] ,
                [u'[03]-[[07]-[06]]', 3, 2, u'three', 0, None, 5, -5, u''] ,
                [u'[03]-[[07]-[07]]', 3, 2, u'three', 0, None, 0, None, u''] ,
                [u'[03]-[[07]-[08]]', 3, 2, u'three', 0, None, None, None, u''] ,
                [u'[03]-[[07]-[09]]', 3, 2, u'three', 0, None, None, 0, u''] ,
                [u'[03]-[[08]-[01]]', 3, 2, u'three', None, None, 1, -1, u''] ,
                [u'[03]-[[08]-[02]]', 3, 2, u'three', None, None, 2, 2, u''] ,
                [u'[03]-[[08]-[03]]', 3, 2, u'three', None, None, 3, -3, u''] ,
                [u'[03]-[[08]-[04]]', 3, 2, u'three', None, None, 2, 4, u''] ,
                [u'[03]-[[08]-[05]]', 3, 2, u'three', None, None, 5, -5, u''] ,
                [u'[03]-[[08]-[06]]', 3, 2, u'three', None, None, 5, -5, u''] ,
                [u'[03]-[[08]-[07]]', 3, 2, u'three', None, None, 0, None, u''] ,
                [u'[03]-[[08]-[08]]', 3, 2, u'three', None, None, None, None, u''] ,
                [u'[03]-[[08]-[09]]', 3, 2, u'three', None, None, None, 0, u''] ,
                [u'[03]-[[09]-[01]]', 3, 2, u'three', None, 0, 1, -1, u''] ,
                [u'[03]-[[09]-[02]]', 3, 2, u'three', None, 0, 2, 2, u''] ,
                [u'[03]-[[09]-[03]]', 3, 2, u'three', None, 0, 3, -3, u''] ,
                [u'[03]-[[09]-[04]]', 3, 2, u'three', None, 0, 2, 4, u''] ,
                [u'[03]-[[09]-[05]]', 3, 2, u'three', None, 0, 5, -5, u''] ,
                [u'[03]-[[09]-[06]]', 3, 2, u'three', None, 0, 5, -5, u''] ,
                [u'[03]-[[09]-[07]]', 3, 2, u'three', None, 0, 0, None, u''] ,
                [u'[03]-[[09]-[08]]', 3, 2, u'three', None, 0, None, None, u''] ,
                [u'[03]-[[09]-[09]]', 3, 2, u'three', None, 0, None, 0, u''] ,
                [u'[04]-[[01]-[01]]', 4, 1, u'four', 1, -1, 1, -1, u''] ,
                [u'[04]-[[01]-[02]]', 4, 1, u'four', 1, -1, 2, 2, u''] ,
                [u'[04]-[[01]-[03]]', 4, 1, u'four', 1, -1, 3, -3, u''] ,
                [u'[04]-[[01]-[04]]', 4, 1, u'four', 1, -1, 2, 4, u''] ,
                [u'[04]-[[01]-[05]]', 4, 1, u'four', 1, -1, 5, -5, u''] ,
                [u'[04]-[[01]-[06]]', 4, 1, u'four', 1, -1, 5, -5, u''] ,
                [u'[04]-[[01]-[07]]', 4, 1, u'four', 1, -1, 0, None, u''] ,
                [u'[04]-[[01]-[08]]', 4, 1, u'four', 1, -1, None, None, u''] ,
                [u'[04]-[[01]-[09]]', 4, 1, u'four', 1, -1, None, 0, u''] ,
                [u'[04]-[[02]-[01]]', 4, 1, u'four', 2, 2, 1, -1, u''] ,
                [u'[04]-[[02]-[02]]', 4, 1, u'four', 2, 2, 2, 2, u''] ,
                [u'[04]-[[02]-[03]]', 4, 1, u'four', 2, 2, 3, -3, u''] ,
                [u'[04]-[[02]-[04]]', 4, 1, u'four', 2, 2, 2, 4, u''] ,
                [u'[04]-[[02]-[05]]', 4, 1, u'four', 2, 2, 5, -5, u''] ,
                [u'[04]-[[02]-[06]]', 4, 1, u'four', 2, 2, 5, -5, u''] ,
                [u'[04]-[[02]-[07]]', 4, 1, u'four', 2, 2, 0, None, u''] ,
                [u'[04]-[[02]-[08]]', 4, 1, u'four', 2, 2, None, None, u''] ,
                [u'[04]-[[02]-[09]]', 4, 1, u'four', 2, 2, None, 0, u''] ,
                [u'[04]-[[03]-[01]]', 4, 1, u'four', 3, -3, 1, -1, u''] ,
                [u'[04]-[[03]-[02]]', 4, 1, u'four', 3, -3, 2, 2, u''] ,
                [u'[04]-[[03]-[03]]', 4, 1, u'four', 3, -3, 3, -3, u''] ,
                [u'[04]-[[03]-[04]]', 4, 1, u'four', 3, -3, 2, 4, u''] ,
                [u'[04]-[[03]-[05]]', 4, 1, u'four', 3, -3, 5, -5, u''] ,
                [u'[04]-[[03]-[06]]', 4, 1, u'four', 3, -3, 5, -5, u''] ,
                [u'[04]-[[03]-[07]]', 4, 1, u'four', 3, -3, 0, None, u''] ,
                [u'[04]-[[03]-[08]]', 4, 1, u'four', 3, -3, None, None, u''] ,
                [u'[04]-[[03]-[09]]', 4, 1, u'four', 3, -3, None, 0, u''] ,
                [u'[04]-[[04]-[01]]', 4, 1, u'four', 2, 4, 1, -1, u''] ,
                [u'[04]-[[04]-[02]]', 4, 1, u'four', 2, 4, 2, 2, u''] ,
                [u'[04]-[[04]-[03]]', 4, 1, u'four', 2, 4, 3, -3, u''] ,
                [u'[04]-[[04]-[04]]', 4, 1, u'four', 2, 4, 2, 4, u''] ,
                [u'[04]-[[04]-[05]]', 4, 1, u'four', 2, 4, 5, -5, u''] ,
                [u'[04]-[[04]-[06]]', 4, 1, u'four', 2, 4, 5, -5, u''] ,
                [u'[04]-[[04]-[07]]', 4, 1, u'four', 2, 4, 0, None, u''] ,
                [u'[04]-[[04]-[08]]', 4, 1, u'four', 2, 4, None, None, u''] ,
                [u'[04]-[[04]-[09]]', 4, 1, u'four', 2, 4, None, 0, u''] ,
                [u'[04]-[[05]-[01]]', 4, 1, u'four', 5, -5, 1, -1, u''] ,
                [u'[04]-[[05]-[02]]', 4, 1, u'four', 5, -5, 2, 2, u''] ,
                [u'[04]-[[05]-[03]]', 4, 1, u'four', 5, -5, 3, -3, u''] ,
                [u'[04]-[[05]-[04]]', 4, 1, u'four', 5, -5, 2, 4, u''] ,
                [u'[04]-[[05]-[05]]', 4, 1, u'four', 5, -5, 5, -5, u''] ,
                [u'[04]-[[05]-[06]]', 4, 1, u'four', 5, -5, 5, -5, u''] ,
                [u'[04]-[[05]-[07]]', 4, 1, u'four', 5, -5, 0, None, u''] ,
                [u'[04]-[[05]-[08]]', 4, 1, u'four', 5, -5, None, None, u''] ,
                [u'[04]-[[05]-[09]]', 4, 1, u'four', 5, -5, None, 0, u''] ,
                [u'[04]-[[06]-[01]]', 4, 1, u'four', 5, -5, 1, -1, u''] ,
                [u'[04]-[[06]-[02]]', 4, 1, u'four', 5, -5, 2, 2, u''] ,
                [u'[04]-[[06]-[03]]', 4, 1, u'four', 5, -5, 3, -3, u''] ,
                [u'[04]-[[06]-[04]]', 4, 1, u'four', 5, -5, 2, 4, u''] ,
                [u'[04]-[[06]-[05]]', 4, 1, u'four', 5, -5, 5, -5, u''] ,
                [u'[04]-[[06]-[06]]', 4, 1, u'four', 5, -5, 5, -5, u''] ,
                [u'[04]-[[06]-[07]]', 4, 1, u'four', 5, -5, 0, None, u''] ,
                [u'[04]-[[06]-[08]]', 4, 1, u'four', 5, -5, None, None, u''] ,
                [u'[04]-[[06]-[09]]', 4, 1, u'four', 5, -5, None, 0, u''] ,
                [u'[04]-[[07]-[01]]', 4, 1, u'four', 0, None, 1, -1, u''] ,
                [u'[04]-[[07]-[02]]', 4, 1, u'four', 0, None, 2, 2, u''] ,
                [u'[04]-[[07]-[03]]', 4, 1, u'four', 0, None, 3, -3, u''] ,
                [u'[04]-[[07]-[04]]', 4, 1, u'four', 0, None, 2, 4, u''] ,
                [u'[04]-[[07]-[05]]', 4, 1, u'four', 0, None, 5, -5, u''] ,
                [u'[04]-[[07]-[06]]', 4, 1, u'four', 0, None, 5, -5, u''] ,
                [u'[04]-[[07]-[07]]', 4, 1, u'four', 0, None, 0, None, u''] ,
                [u'[04]-[[07]-[08]]', 4, 1, u'four', 0, None, None, None, u''] ,
                [u'[04]-[[07]-[09]]', 4, 1, u'four', 0, None, None, 0, u''] ,
                [u'[04]-[[08]-[01]]', 4, 1, u'four', None, None, 1, -1, u''] ,
                [u'[04]-[[08]-[02]]', 4, 1, u'four', None, None, 2, 2, u''] ,
                [u'[04]-[[08]-[03]]', 4, 1, u'four', None, None, 3, -3, u''] ,
                [u'[04]-[[08]-[04]]', 4, 1, u'four', None, None, 2, 4, u''] ,
                [u'[04]-[[08]-[05]]', 4, 1, u'four', None, None, 5, -5, u''] ,
                [u'[04]-[[08]-[06]]', 4, 1, u'four', None, None, 5, -5, u''] ,
                [u'[04]-[[08]-[07]]', 4, 1, u'four', None, None, 0, None, u''] ,
                [u'[04]-[[08]-[08]]', 4, 1, u'four', None, None, None, None, u''] ,
                [u'[04]-[[08]-[09]]', 4, 1, u'four', None, None, None, 0, u''] ,
                [u'[04]-[[09]-[01]]', 4, 1, u'four', None, 0, 1, -1, u''] ,
                [u'[04]-[[09]-[02]]', 4, 1, u'four', None, 0, 2, 2, u''] ,
                [u'[04]-[[09]-[03]]', 4, 1, u'four', None, 0, 3, -3, u''] ,
                [u'[04]-[[09]-[04]]', 4, 1, u'four', None, 0, 2, 4, u''] ,
                [u'[04]-[[09]-[05]]', 4, 1, u'four', None, 0, 5, -5, u''] ,
                [u'[04]-[[09]-[06]]', 4, 1, u'four', None, 0, 5, -5, u''] ,
                [u'[04]-[[09]-[07]]', 4, 1, u'four', None, 0, 0, None, u''] ,
                [u'[04]-[[09]-[08]]', 4, 1, u'four', None, 0, None, None, u''] ,
                [u'[04]-[[09]-[09]]', 4, 1, u'four', None, 0, None, 0, u''] ,
                [u'[05]-[[01]-[01]]', 5, 0, u'five', 1, -1, 1, -1, u''] ,
                [u'[05]-[[01]-[02]]', 5, 0, u'five', 1, -1, 2, 2, u''] ,
                [u'[05]-[[01]-[03]]', 5, 0, u'five', 1, -1, 3, -3, u''] ,
                [u'[05]-[[01]-[04]]', 5, 0, u'five', 1, -1, 2, 4, u''] ,
                [u'[05]-[[01]-[05]]', 5, 0, u'five', 1, -1, 5, -5, u''] ,
                [u'[05]-[[01]-[06]]', 5, 0, u'five', 1, -1, 5, -5, u''] ,
                [u'[05]-[[01]-[07]]', 5, 0, u'five', 1, -1, 0, None, u''] ,
                [u'[05]-[[01]-[08]]', 5, 0, u'five', 1, -1, None, None, u''] ,
                [u'[05]-[[01]-[09]]', 5, 0, u'five', 1, -1, None, 0, u''] ,
                [u'[05]-[[02]-[01]]', 5, 0, u'five', 2, 2, 1, -1, u''] ,
                [u'[05]-[[02]-[02]]', 5, 0, u'five', 2, 2, 2, 2, u''] ,
                [u'[05]-[[02]-[03]]', 5, 0, u'five', 2, 2, 3, -3, u''] ,
                [u'[05]-[[02]-[04]]', 5, 0, u'five', 2, 2, 2, 4, u''] ,
                [u'[05]-[[02]-[05]]', 5, 0, u'five', 2, 2, 5, -5, u''] ,
                [u'[05]-[[02]-[06]]', 5, 0, u'five', 2, 2, 5, -5, u''] ,
                [u'[05]-[[02]-[07]]', 5, 0, u'five', 2, 2, 0, None, u''] ,
                [u'[05]-[[02]-[08]]', 5, 0, u'five', 2, 2, None, None, u''] ,
                [u'[05]-[[02]-[09]]', 5, 0, u'five', 2, 2, None, 0, u''] ,
                [u'[05]-[[03]-[01]]', 5, 0, u'five', 3, -3, 1, -1, u''] ,
                [u'[05]-[[03]-[02]]', 5, 0, u'five', 3, -3, 2, 2, u''] ,
                [u'[05]-[[03]-[03]]', 5, 0, u'five', 3, -3, 3, -3, u''] ,
                [u'[05]-[[03]-[04]]', 5, 0, u'five', 3, -3, 2, 4, u''] ,
                [u'[05]-[[03]-[05]]', 5, 0, u'five', 3, -3, 5, -5, u''] ,
                [u'[05]-[[03]-[06]]', 5, 0, u'five', 3, -3, 5, -5, u''] ,
                [u'[05]-[[03]-[07]]', 5, 0, u'five', 3, -3, 0, None, u''] ,
                [u'[05]-[[03]-[08]]', 5, 0, u'five', 3, -3, None, None, u''] ,
                [u'[05]-[[03]-[09]]', 5, 0, u'five', 3, -3, None, 0, u''] ,
                [u'[05]-[[04]-[01]]', 5, 0, u'five', 2, 4, 1, -1, u''] ,
                [u'[05]-[[04]-[02]]', 5, 0, u'five', 2, 4, 2, 2, u''] ,
                [u'[05]-[[04]-[03]]', 5, 0, u'five', 2, 4, 3, -3, u''] ,
                [u'[05]-[[04]-[04]]', 5, 0, u'five', 2, 4, 2, 4, u''] ,
                [u'[05]-[[04]-[05]]', 5, 0, u'five', 2, 4, 5, -5, u''] ,
                [u'[05]-[[04]-[06]]', 5, 0, u'five', 2, 4, 5, -5, u''] ,
                [u'[05]-[[04]-[07]]', 5, 0, u'five', 2, 4, 0, None, u''] ,
                [u'[05]-[[04]-[08]]', 5, 0, u'five', 2, 4, None, None, u''] ,
                [u'[05]-[[04]-[09]]', 5, 0, u'five', 2, 4, None, 0, u''] ,
                [u'[05]-[[05]-[01]]', 5, 0, u'five', 5, -5, 1, -1, u''] ,
                [u'[05]-[[05]-[02]]', 5, 0, u'five', 5, -5, 2, 2, u''] ,
                [u'[05]-[[05]-[03]]', 5, 0, u'five', 5, -5, 3, -3, u''] ,
                [u'[05]-[[05]-[04]]', 5, 0, u'five', 5, -5, 2, 4, u''] ,
                [u'[05]-[[05]-[05]]', 5, 0, u'five', 5, -5, 5, -5, u''] ,
                [u'[05]-[[05]-[06]]', 5, 0, u'five', 5, -5, 5, -5, u''] ,
                [u'[05]-[[05]-[07]]', 5, 0, u'five', 5, -5, 0, None, u''] ,
                [u'[05]-[[05]-[08]]', 5, 0, u'five', 5, -5, None, None, u''] ,
                [u'[05]-[[05]-[09]]', 5, 0, u'five', 5, -5, None, 0, u''] ,
                [u'[05]-[[06]-[01]]', 5, 0, u'five', 5, -5, 1, -1, u''] ,
                [u'[05]-[[06]-[02]]', 5, 0, u'five', 5, -5, 2, 2, u''] ,
                [u'[05]-[[06]-[03]]', 5, 0, u'five', 5, -5, 3, -3, u''] ,
                [u'[05]-[[06]-[04]]', 5, 0, u'five', 5, -5, 2, 4, u''] ,
                [u'[05]-[[06]-[05]]', 5, 0, u'five', 5, -5, 5, -5, u''] ,
                [u'[05]-[[06]-[06]]', 5, 0, u'five', 5, -5, 5, -5, u''] ,
                [u'[05]-[[06]-[07]]', 5, 0, u'five', 5, -5, 0, None, u''] ,
                [u'[05]-[[06]-[08]]', 5, 0, u'five', 5, -5, None, None, u''] ,
                [u'[05]-[[06]-[09]]', 5, 0, u'five', 5, -5, None, 0, u''] ,
                [u'[05]-[[07]-[01]]', 5, 0, u'five', 0, None, 1, -1, u''] ,
                [u'[05]-[[07]-[02]]', 5, 0, u'five', 0, None, 2, 2, u''] ,
                [u'[05]-[[07]-[03]]', 5, 0, u'five', 0, None, 3, -3, u''] ,
                [u'[05]-[[07]-[04]]', 5, 0, u'five', 0, None, 2, 4, u''] ,
                [u'[05]-[[07]-[05]]', 5, 0, u'five', 0, None, 5, -5, u''] ,
                [u'[05]-[[07]-[06]]', 5, 0, u'five', 0, None, 5, -5, u''] ,
                [u'[05]-[[07]-[07]]', 5, 0, u'five', 0, None, 0, None, u''] ,
                [u'[05]-[[07]-[08]]', 5, 0, u'five', 0, None, None, None, u''] ,
                [u'[05]-[[07]-[09]]', 5, 0, u'five', 0, None, None, 0, u''] ,
                [u'[05]-[[08]-[01]]', 5, 0, u'five', None, None, 1, -1, u''] ,
                [u'[05]-[[08]-[02]]', 5, 0, u'five', None, None, 2, 2, u''] ,
                [u'[05]-[[08]-[03]]', 5, 0, u'five', None, None, 3, -3, u''] ,
                [u'[05]-[[08]-[04]]', 5, 0, u'five', None, None, 2, 4, u''] ,
                [u'[05]-[[08]-[05]]', 5, 0, u'five', None, None, 5, -5, u''] ,
                [u'[05]-[[08]-[06]]', 5, 0, u'five', None, None, 5, -5, u''] ,
                [u'[05]-[[08]-[07]]', 5, 0, u'five', None, None, 0, None, u''] ,
                [u'[05]-[[08]-[08]]', 5, 0, u'five', None, None, None, None, u''] ,
                [u'[05]-[[08]-[09]]', 5, 0, u'five', None, None, None, 0, u''] ,
                [u'[05]-[[09]-[01]]', 5, 0, u'five', None, 0, 1, -1, u''] ,
                [u'[05]-[[09]-[02]]', 5, 0, u'five', None, 0, 2, 2, u''] ,
                [u'[05]-[[09]-[03]]', 5, 0, u'five', None, 0, 3, -3, u''] ,
                [u'[05]-[[09]-[04]]', 5, 0, u'five', None, 0, 2, 4, u''] ,
                [u'[05]-[[09]-[05]]', 5, 0, u'five', None, 0, 5, -5, u''] ,
                [u'[05]-[[09]-[06]]', 5, 0, u'five', None, 0, 5, -5, u''] ,
                [u'[05]-[[09]-[07]]', 5, 0, u'five', None, 0, 0, None, u''] ,
                [u'[05]-[[09]-[08]]', 5, 0, u'five', None, 0, None, None, u''] ,
                [u'[05]-[[09]-[09]]', 5, 0, u'five', None, 0, None, 0, u''] ,
                [u'[06]-[[01]-[01]]', 6, 6, u'six', 1, -1, 1, -1, u''] ,
                [u'[06]-[[01]-[02]]', 6, 6, u'six', 1, -1, 2, 2, u''] ,
                [u'[06]-[[01]-[03]]', 6, 6, u'six', 1, -1, 3, -3, u''] ,
                [u'[06]-[[01]-[04]]', 6, 6, u'six', 1, -1, 2, 4, u''] ,
                [u'[06]-[[01]-[05]]', 6, 6, u'six', 1, -1, 5, -5, u''] ,
                [u'[06]-[[01]-[06]]', 6, 6, u'six', 1, -1, 5, -5, u''] ,
                [u'[06]-[[01]-[07]]', 6, 6, u'six', 1, -1, 0, None, u''] ,
                [u'[06]-[[01]-[08]]', 6, 6, u'six', 1, -1, None, None, u''] ,
                [u'[06]-[[01]-[09]]', 6, 6, u'six', 1, -1, None, 0, u''] ,
                [u'[06]-[[02]-[01]]', 6, 6, u'six', 2, 2, 1, -1, u''] ,
                [u'[06]-[[02]-[02]]', 6, 6, u'six', 2, 2, 2, 2, u''] ,
                [u'[06]-[[02]-[03]]', 6, 6, u'six', 2, 2, 3, -3, u''] ,
                [u'[06]-[[02]-[04]]', 6, 6, u'six', 2, 2, 2, 4, u''] ,
                [u'[06]-[[02]-[05]]', 6, 6, u'six', 2, 2, 5, -5, u''] ,
                [u'[06]-[[02]-[06]]', 6, 6, u'six', 2, 2, 5, -5, u''] ,
                [u'[06]-[[02]-[07]]', 6, 6, u'six', 2, 2, 0, None, u''] ,
                [u'[06]-[[02]-[08]]', 6, 6, u'six', 2, 2, None, None, u''] ,
                [u'[06]-[[02]-[09]]', 6, 6, u'six', 2, 2, None, 0, u''] ,
                [u'[06]-[[03]-[01]]', 6, 6, u'six', 3, -3, 1, -1, u''] ,
                [u'[06]-[[03]-[02]]', 6, 6, u'six', 3, -3, 2, 2, u''] ,
                [u'[06]-[[03]-[03]]', 6, 6, u'six', 3, -3, 3, -3, u''] ,
                [u'[06]-[[03]-[04]]', 6, 6, u'six', 3, -3, 2, 4, u''] ,
                [u'[06]-[[03]-[05]]', 6, 6, u'six', 3, -3, 5, -5, u''] ,
                [u'[06]-[[03]-[06]]', 6, 6, u'six', 3, -3, 5, -5, u''] ,
                [u'[06]-[[03]-[07]]', 6, 6, u'six', 3, -3, 0, None, u''] ,
                [u'[06]-[[03]-[08]]', 6, 6, u'six', 3, -3, None, None, u''] ,
                [u'[06]-[[03]-[09]]', 6, 6, u'six', 3, -3, None, 0, u''] ,
                [u'[06]-[[04]-[01]]', 6, 6, u'six', 2, 4, 1, -1, u''] ,
                [u'[06]-[[04]-[02]]', 6, 6, u'six', 2, 4, 2, 2, u''] ,
                [u'[06]-[[04]-[03]]', 6, 6, u'six', 2, 4, 3, -3, u''] ,
                [u'[06]-[[04]-[04]]', 6, 6, u'six', 2, 4, 2, 4, u''] ,
                [u'[06]-[[04]-[05]]', 6, 6, u'six', 2, 4, 5, -5, u''] ,
                [u'[06]-[[04]-[06]]', 6, 6, u'six', 2, 4, 5, -5, u''] ,
                [u'[06]-[[04]-[07]]', 6, 6, u'six', 2, 4, 0, None, u''] ,
                [u'[06]-[[04]-[08]]', 6, 6, u'six', 2, 4, None, None, u''] ,
                [u'[06]-[[04]-[09]]', 6, 6, u'six', 2, 4, None, 0, u''] ,
                [u'[06]-[[05]-[01]]', 6, 6, u'six', 5, -5, 1, -1, u''] ,
                [u'[06]-[[05]-[02]]', 6, 6, u'six', 5, -5, 2, 2, u''] ,
                [u'[06]-[[05]-[03]]', 6, 6, u'six', 5, -5, 3, -3, u''] ,
                [u'[06]-[[05]-[04]]', 6, 6, u'six', 5, -5, 2, 4, u''] ,
                [u'[06]-[[05]-[05]]', 6, 6, u'six', 5, -5, 5, -5, u''] ,
                [u'[06]-[[05]-[06]]', 6, 6, u'six', 5, -5, 5, -5, u''] ,
                [u'[06]-[[05]-[07]]', 6, 6, u'six', 5, -5, 0, None, u''] ,
                [u'[06]-[[05]-[08]]', 6, 6, u'six', 5, -5, None, None, u''] ,
                [u'[06]-[[05]-[09]]', 6, 6, u'six', 5, -5, None, 0, u''] ,
                [u'[06]-[[06]-[01]]', 6, 6, u'six', 5, -5, 1, -1, u''] ,
                [u'[06]-[[06]-[02]]', 6, 6, u'six', 5, -5, 2, 2, u''] ,
                [u'[06]-[[06]-[03]]', 6, 6, u'six', 5, -5, 3, -3, u''] ,
                [u'[06]-[[06]-[04]]', 6, 6, u'six', 5, -5, 2, 4, u''] ,
                [u'[06]-[[06]-[05]]', 6, 6, u'six', 5, -5, 5, -5, u''] ,
                [u'[06]-[[06]-[06]]', 6, 6, u'six', 5, -5, 5, -5, u''] ,
                [u'[06]-[[06]-[07]]', 6, 6, u'six', 5, -5, 0, None, u''] ,
                [u'[06]-[[06]-[08]]', 6, 6, u'six', 5, -5, None, None, u''] ,
                [u'[06]-[[06]-[09]]', 6, 6, u'six', 5, -5, None, 0, u''] ,
                [u'[06]-[[07]-[01]]', 6, 6, u'six', 0, None, 1, -1, u''] ,
                [u'[06]-[[07]-[02]]', 6, 6, u'six', 0, None, 2, 2, u''] ,
                [u'[06]-[[07]-[03]]', 6, 6, u'six', 0, None, 3, -3, u''] ,
                [u'[06]-[[07]-[04]]', 6, 6, u'six', 0, None, 2, 4, u''] ,
                [u'[06]-[[07]-[05]]', 6, 6, u'six', 0, None, 5, -5, u''] ,
                [u'[06]-[[07]-[06]]', 6, 6, u'six', 0, None, 5, -5, u''] ,
                [u'[06]-[[07]-[07]]', 6, 6, u'six', 0, None, 0, None, u''] ,
                [u'[06]-[[07]-[08]]', 6, 6, u'six', 0, None, None, None, u''] ,
                [u'[06]-[[07]-[09]]', 6, 6, u'six', 0, None, None, 0, u''] ,
                [u'[06]-[[08]-[01]]', 6, 6, u'six', None, None, 1, -1, u''] ,
                [u'[06]-[[08]-[02]]', 6, 6, u'six', None, None, 2, 2, u''] ,
                [u'[06]-[[08]-[03]]', 6, 6, u'six', None, None, 3, -3, u''] ,
                [u'[06]-[[08]-[04]]', 6, 6, u'six', None, None, 2, 4, u''] ,
                [u'[06]-[[08]-[05]]', 6, 6, u'six', None, None, 5, -5, u''] ,
                [u'[06]-[[08]-[06]]', 6, 6, u'six', None, None, 5, -5, u''] ,
                [u'[06]-[[08]-[07]]', 6, 6, u'six', None, None, 0, None, u''] ,
                [u'[06]-[[08]-[08]]', 6, 6, u'six', None, None, None, None, u''] ,
                [u'[06]-[[08]-[09]]', 6, 6, u'six', None, None, None, 0, u''] ,
                [u'[06]-[[09]-[01]]', 6, 6, u'six', None, 0, 1, -1, u''] ,
                [u'[06]-[[09]-[02]]', 6, 6, u'six', None, 0, 2, 2, u''] ,
                [u'[06]-[[09]-[03]]', 6, 6, u'six', None, 0, 3, -3, u''] ,
                [u'[06]-[[09]-[04]]', 6, 6, u'six', None, 0, 2, 4, u''] ,
                [u'[06]-[[09]-[05]]', 6, 6, u'six', None, 0, 5, -5, u''] ,
                [u'[06]-[[09]-[06]]', 6, 6, u'six', None, 0, 5, -5, u''] ,
                [u'[06]-[[09]-[07]]', 6, 6, u'six', None, 0, 0, None, u''] ,
                [u'[06]-[[09]-[08]]', 6, 6, u'six', None, 0, None, None, u''] ,
                [u'[06]-[[09]-[09]]', 6, 6, u'six', None, 0, None, 0, u''] ,
                [u'[07]-[[01]-[01]]', 7, 7, u'seven', 1, -1, 1, -1, u''] ,
                [u'[07]-[[01]-[02]]', 7, 7, u'seven', 1, -1, 2, 2, u''] ,
                [u'[07]-[[01]-[03]]', 7, 7, u'seven', 1, -1, 3, -3, u''] ,
                [u'[07]-[[01]-[04]]', 7, 7, u'seven', 1, -1, 2, 4, u''] ,
                [u'[07]-[[01]-[05]]', 7, 7, u'seven', 1, -1, 5, -5, u''] ,
                [u'[07]-[[01]-[06]]', 7, 7, u'seven', 1, -1, 5, -5, u''] ,
                [u'[07]-[[01]-[07]]', 7, 7, u'seven', 1, -1, 0, None, u''] ,
                [u'[07]-[[01]-[08]]', 7, 7, u'seven', 1, -1, None, None, u''] ,
                [u'[07]-[[01]-[09]]', 7, 7, u'seven', 1, -1, None, 0, u''] ,
                [u'[07]-[[02]-[01]]', 7, 7, u'seven', 2, 2, 1, -1, u''] ,
                [u'[07]-[[02]-[02]]', 7, 7, u'seven', 2, 2, 2, 2, u''] ,
                [u'[07]-[[02]-[03]]', 7, 7, u'seven', 2, 2, 3, -3, u''] ,
                [u'[07]-[[02]-[04]]', 7, 7, u'seven', 2, 2, 2, 4, u''] ,
                [u'[07]-[[02]-[05]]', 7, 7, u'seven', 2, 2, 5, -5, u''] ,
                [u'[07]-[[02]-[06]]', 7, 7, u'seven', 2, 2, 5, -5, u''] ,
                [u'[07]-[[02]-[07]]', 7, 7, u'seven', 2, 2, 0, None, u''] ,
                [u'[07]-[[02]-[08]]', 7, 7, u'seven', 2, 2, None, None, u''] ,
                [u'[07]-[[02]-[09]]', 7, 7, u'seven', 2, 2, None, 0, u''] ,
                [u'[07]-[[03]-[01]]', 7, 7, u'seven', 3, -3, 1, -1, u''] ,
                [u'[07]-[[03]-[02]]', 7, 7, u'seven', 3, -3, 2, 2, u''] ,
                [u'[07]-[[03]-[03]]', 7, 7, u'seven', 3, -3, 3, -3, u''] ,
                [u'[07]-[[03]-[04]]', 7, 7, u'seven', 3, -3, 2, 4, u''] ,
                [u'[07]-[[03]-[05]]', 7, 7, u'seven', 3, -3, 5, -5, u''] ,
                [u'[07]-[[03]-[06]]', 7, 7, u'seven', 3, -3, 5, -5, u''] ,
                [u'[07]-[[03]-[07]]', 7, 7, u'seven', 3, -3, 0, None, u''] ,
                [u'[07]-[[03]-[08]]', 7, 7, u'seven', 3, -3, None, None, u''] ,
                [u'[07]-[[03]-[09]]', 7, 7, u'seven', 3, -3, None, 0, u''] ,
                [u'[07]-[[04]-[01]]', 7, 7, u'seven', 2, 4, 1, -1, u''] ,
                [u'[07]-[[04]-[02]]', 7, 7, u'seven', 2, 4, 2, 2, u''] ,
                [u'[07]-[[04]-[03]]', 7, 7, u'seven', 2, 4, 3, -3, u''] ,
                [u'[07]-[[04]-[04]]', 7, 7, u'seven', 2, 4, 2, 4, u''] ,
                [u'[07]-[[04]-[05]]', 7, 7, u'seven', 2, 4, 5, -5, u''] ,
                [u'[07]-[[04]-[06]]', 7, 7, u'seven', 2, 4, 5, -5, u''] ,
                [u'[07]-[[04]-[07]]', 7, 7, u'seven', 2, 4, 0, None, u''] ,
                [u'[07]-[[04]-[08]]', 7, 7, u'seven', 2, 4, None, None, u''] ,
                [u'[07]-[[04]-[09]]', 7, 7, u'seven', 2, 4, None, 0, u''] ,
                [u'[07]-[[05]-[01]]', 7, 7, u'seven', 5, -5, 1, -1, u''] ,
                [u'[07]-[[05]-[02]]', 7, 7, u'seven', 5, -5, 2, 2, u''] ,
                [u'[07]-[[05]-[03]]', 7, 7, u'seven', 5, -5, 3, -3, u''] ,
                [u'[07]-[[05]-[04]]', 7, 7, u'seven', 5, -5, 2, 4, u''] ,
                [u'[07]-[[05]-[05]]', 7, 7, u'seven', 5, -5, 5, -5, u''] ,
                [u'[07]-[[05]-[06]]', 7, 7, u'seven', 5, -5, 5, -5, u''] ,
                [u'[07]-[[05]-[07]]', 7, 7, u'seven', 5, -5, 0, None, u''] ,
                [u'[07]-[[05]-[08]]', 7, 7, u'seven', 5, -5, None, None, u''] ,
                [u'[07]-[[05]-[09]]', 7, 7, u'seven', 5, -5, None, 0, u''] ,
                [u'[07]-[[06]-[01]]', 7, 7, u'seven', 5, -5, 1, -1, u''] ,
                [u'[07]-[[06]-[02]]', 7, 7, u'seven', 5, -5, 2, 2, u''] ,
                [u'[07]-[[06]-[03]]', 7, 7, u'seven', 5, -5, 3, -3, u''] ,
                [u'[07]-[[06]-[04]]', 7, 7, u'seven', 5, -5, 2, 4, u''] ,
                [u'[07]-[[06]-[05]]', 7, 7, u'seven', 5, -5, 5, -5, u''] ,
                [u'[07]-[[06]-[06]]', 7, 7, u'seven', 5, -5, 5, -5, u''] ,
                [u'[07]-[[06]-[07]]', 7, 7, u'seven', 5, -5, 0, None, u''] ,
                [u'[07]-[[06]-[08]]', 7, 7, u'seven', 5, -5, None, None, u''] ,
                [u'[07]-[[06]-[09]]', 7, 7, u'seven', 5, -5, None, 0, u''] ,
                [u'[07]-[[07]-[01]]', 7, 7, u'seven', 0, None, 1, -1, u''] ,
                [u'[07]-[[07]-[02]]', 7, 7, u'seven', 0, None, 2, 2, u''] ,
                [u'[07]-[[07]-[03]]', 7, 7, u'seven', 0, None, 3, -3, u''] ,
                [u'[07]-[[07]-[04]]', 7, 7, u'seven', 0, None, 2, 4, u''] ,
                [u'[07]-[[07]-[05]]', 7, 7, u'seven', 0, None, 5, -5, u''] ,
                [u'[07]-[[07]-[06]]', 7, 7, u'seven', 0, None, 5, -5, u''] ,
                [u'[07]-[[07]-[07]]', 7, 7, u'seven', 0, None, 0, None, u''] ,
                [u'[07]-[[07]-[08]]', 7, 7, u'seven', 0, None, None, None, u''] ,
                [u'[07]-[[07]-[09]]', 7, 7, u'seven', 0, None, None, 0, u''] ,
                [u'[07]-[[08]-[01]]', 7, 7, u'seven', None, None, 1, -1, u''] ,
                [u'[07]-[[08]-[02]]', 7, 7, u'seven', None, None, 2, 2, u''] ,
                [u'[07]-[[08]-[03]]', 7, 7, u'seven', None, None, 3, -3, u''] ,
                [u'[07]-[[08]-[04]]', 7, 7, u'seven', None, None, 2, 4, u''] ,
                [u'[07]-[[08]-[05]]', 7, 7, u'seven', None, None, 5, -5, u''] ,
                [u'[07]-[[08]-[06]]', 7, 7, u'seven', None, None, 5, -5, u''] ,
                [u'[07]-[[08]-[07]]', 7, 7, u'seven', None, None, 0, None, u''] ,
                [u'[07]-[[08]-[08]]', 7, 7, u'seven', None, None, None, None, u''] ,
                [u'[07]-[[08]-[09]]', 7, 7, u'seven', None, None, None, 0, u''] ,
                [u'[07]-[[09]-[01]]', 7, 7, u'seven', None, 0, 1, -1, u''] ,
                [u'[07]-[[09]-[02]]', 7, 7, u'seven', None, 0, 2, 2, u''] ,
                [u'[07]-[[09]-[03]]', 7, 7, u'seven', None, 0, 3, -3, u''] ,
                [u'[07]-[[09]-[04]]', 7, 7, u'seven', None, 0, 2, 4, u''] ,
                [u'[07]-[[09]-[05]]', 7, 7, u'seven', None, 0, 5, -5, u''] ,
                [u'[07]-[[09]-[06]]', 7, 7, u'seven', None, 0, 5, -5, u''] ,
                [u'[07]-[[09]-[07]]', 7, 7, u'seven', None, 0, 0, None, u''] ,
                [u'[07]-[[09]-[08]]', 7, 7, u'seven', None, 0, None, None, u''] ,
                [u'[07]-[[09]-[09]]', 7, 7, u'seven', None, 0, None, 0, u''] ,
                [u'[08]-[[01]-[01]]', 8, 8, u'eight', 1, -1, 1, -1, u''] ,
                [u'[08]-[[01]-[02]]', 8, 8, u'eight', 1, -1, 2, 2, u''] ,
                [u'[08]-[[01]-[03]]', 8, 8, u'eight', 1, -1, 3, -3, u''] ,
                [u'[08]-[[01]-[04]]', 8, 8, u'eight', 1, -1, 2, 4, u''] ,
                [u'[08]-[[01]-[05]]', 8, 8, u'eight', 1, -1, 5, -5, u''] ,
                [u'[08]-[[01]-[06]]', 8, 8, u'eight', 1, -1, 5, -5, u''] ,
                [u'[08]-[[01]-[07]]', 8, 8, u'eight', 1, -1, 0, None, u''] ,
                [u'[08]-[[01]-[08]]', 8, 8, u'eight', 1, -1, None, None, u''] ,
                [u'[08]-[[01]-[09]]', 8, 8, u'eight', 1, -1, None, 0, u''] ,
                [u'[08]-[[02]-[01]]', 8, 8, u'eight', 2, 2, 1, -1, u''] ,
                [u'[08]-[[02]-[02]]', 8, 8, u'eight', 2, 2, 2, 2, u''] ,
                [u'[08]-[[02]-[03]]', 8, 8, u'eight', 2, 2, 3, -3, u''] ,
                [u'[08]-[[02]-[04]]', 8, 8, u'eight', 2, 2, 2, 4, u''] ,
                [u'[08]-[[02]-[05]]', 8, 8, u'eight', 2, 2, 5, -5, u''] ,
                [u'[08]-[[02]-[06]]', 8, 8, u'eight', 2, 2, 5, -5, u''] ,
                [u'[08]-[[02]-[07]]', 8, 8, u'eight', 2, 2, 0, None, u''] ,
                [u'[08]-[[02]-[08]]', 8, 8, u'eight', 2, 2, None, None, u''] ,
                [u'[08]-[[02]-[09]]', 8, 8, u'eight', 2, 2, None, 0, u''] ,
                [u'[08]-[[03]-[01]]', 8, 8, u'eight', 3, -3, 1, -1, u''] ,
                [u'[08]-[[03]-[02]]', 8, 8, u'eight', 3, -3, 2, 2, u''] ,
                [u'[08]-[[03]-[03]]', 8, 8, u'eight', 3, -3, 3, -3, u''] ,
                [u'[08]-[[03]-[04]]', 8, 8, u'eight', 3, -3, 2, 4, u''] ,
                [u'[08]-[[03]-[05]]', 8, 8, u'eight', 3, -3, 5, -5, u''] ,
                [u'[08]-[[03]-[06]]', 8, 8, u'eight', 3, -3, 5, -5, u''] ,
                [u'[08]-[[03]-[07]]', 8, 8, u'eight', 3, -3, 0, None, u''] ,
                [u'[08]-[[03]-[08]]', 8, 8, u'eight', 3, -3, None, None, u''] ,
                [u'[08]-[[03]-[09]]', 8, 8, u'eight', 3, -3, None, 0, u''] ,
                [u'[08]-[[04]-[01]]', 8, 8, u'eight', 2, 4, 1, -1, u''] ,
                [u'[08]-[[04]-[02]]', 8, 8, u'eight', 2, 4, 2, 2, u''] ,
                [u'[08]-[[04]-[03]]', 8, 8, u'eight', 2, 4, 3, -3, u''] ,
                [u'[08]-[[04]-[04]]', 8, 8, u'eight', 2, 4, 2, 4, u''] ,
                [u'[08]-[[04]-[05]]', 8, 8, u'eight', 2, 4, 5, -5, u''] ,
                [u'[08]-[[04]-[06]]', 8, 8, u'eight', 2, 4, 5, -5, u''] ,
                [u'[08]-[[04]-[07]]', 8, 8, u'eight', 2, 4, 0, None, u''] ,
                [u'[08]-[[04]-[08]]', 8, 8, u'eight', 2, 4, None, None, u''] ,
                [u'[08]-[[04]-[09]]', 8, 8, u'eight', 2, 4, None, 0, u''] ,
                [u'[08]-[[05]-[01]]', 8, 8, u'eight', 5, -5, 1, -1, u''] ,
                [u'[08]-[[05]-[02]]', 8, 8, u'eight', 5, -5, 2, 2, u''] ,
                [u'[08]-[[05]-[03]]', 8, 8, u'eight', 5, -5, 3, -3, u''] ,
                [u'[08]-[[05]-[04]]', 8, 8, u'eight', 5, -5, 2, 4, u''] ,
                [u'[08]-[[05]-[05]]', 8, 8, u'eight', 5, -5, 5, -5, u''] ,
                [u'[08]-[[05]-[06]]', 8, 8, u'eight', 5, -5, 5, -5, u''] ,
                [u'[08]-[[05]-[07]]', 8, 8, u'eight', 5, -5, 0, None, u''] ,
                [u'[08]-[[05]-[08]]', 8, 8, u'eight', 5, -5, None, None, u''] ,
                [u'[08]-[[05]-[09]]', 8, 8, u'eight', 5, -5, None, 0, u''] ,
                [u'[08]-[[06]-[01]]', 8, 8, u'eight', 5, -5, 1, -1, u''] ,
                [u'[08]-[[06]-[02]]', 8, 8, u'eight', 5, -5, 2, 2, u''] ,
                [u'[08]-[[06]-[03]]', 8, 8, u'eight', 5, -5, 3, -3, u''] ,
                [u'[08]-[[06]-[04]]', 8, 8, u'eight', 5, -5, 2, 4, u''] ,
                [u'[08]-[[06]-[05]]', 8, 8, u'eight', 5, -5, 5, -5, u''] ,
                [u'[08]-[[06]-[06]]', 8, 8, u'eight', 5, -5, 5, -5, u''] ,
                [u'[08]-[[06]-[07]]', 8, 8, u'eight', 5, -5, 0, None, u''] ,
                [u'[08]-[[06]-[08]]', 8, 8, u'eight', 5, -5, None, None, u''] ,
                [u'[08]-[[06]-[09]]', 8, 8, u'eight', 5, -5, None, 0, u''] ,
                [u'[08]-[[07]-[01]]', 8, 8, u'eight', 0, None, 1, -1, u''] ,
                [u'[08]-[[07]-[02]]', 8, 8, u'eight', 0, None, 2, 2, u''] ,
                [u'[08]-[[07]-[03]]', 8, 8, u'eight', 0, None, 3, -3, u''] ,
                [u'[08]-[[07]-[04]]', 8, 8, u'eight', 0, None, 2, 4, u''] ,
                [u'[08]-[[07]-[05]]', 8, 8, u'eight', 0, None, 5, -5, u''] ,
                [u'[08]-[[07]-[06]]', 8, 8, u'eight', 0, None, 5, -5, u''] ,
                [u'[08]-[[07]-[07]]', 8, 8, u'eight', 0, None, 0, None, u''] ,
                [u'[08]-[[07]-[08]]', 8, 8, u'eight', 0, None, None, None, u''] ,
                [u'[08]-[[07]-[09]]', 8, 8, u'eight', 0, None, None, 0, u''] ,
                [u'[08]-[[08]-[01]]', 8, 8, u'eight', None, None, 1, -1, u''] ,
                [u'[08]-[[08]-[02]]', 8, 8, u'eight', None, None, 2, 2, u''] ,
                [u'[08]-[[08]-[03]]', 8, 8, u'eight', None, None, 3, -3, u''] ,
                [u'[08]-[[08]-[04]]', 8, 8, u'eight', None, None, 2, 4, u''] ,
                [u'[08]-[[08]-[05]]', 8, 8, u'eight', None, None, 5, -5, u''] ,
                [u'[08]-[[08]-[06]]', 8, 8, u'eight', None, None, 5, -5, u''] ,
                [u'[08]-[[08]-[07]]', 8, 8, u'eight', None, None, 0, None, u''] ,
                [u'[08]-[[08]-[08]]', 8, 8, u'eight', None, None, None, None, u''] ,
                [u'[08]-[[08]-[09]]', 8, 8, u'eight', None, None, None, 0, u''] ,
                [u'[08]-[[09]-[01]]', 8, 8, u'eight', None, 0, 1, -1, u''] ,
                [u'[08]-[[09]-[02]]', 8, 8, u'eight', None, 0, 2, 2, u''] ,
                [u'[08]-[[09]-[03]]', 8, 8, u'eight', None, 0, 3, -3, u''] ,
                [u'[08]-[[09]-[04]]', 8, 8, u'eight', None, 0, 2, 4, u''] ,
                [u'[08]-[[09]-[05]]', 8, 8, u'eight', None, 0, 5, -5, u''] ,
                [u'[08]-[[09]-[06]]', 8, 8, u'eight', None, 0, 5, -5, u''] ,
                [u'[08]-[[09]-[07]]', 8, 8, u'eight', None, 0, 0, None, u''] ,
                [u'[08]-[[09]-[08]]', 8, 8, u'eight', None, 0, None, None, u''] ,
                [u'[08]-[[09]-[09]]', 8, 8, u'eight', None, 0, None, 0, u''] ,
                [u'[09]-[[01]-[01]]', 0, None, u'zero', 1, -1, 1, -1, u''] ,
                [u'[09]-[[01]-[02]]', 0, None, u'zero', 1, -1, 2, 2, u''] ,
                [u'[09]-[[01]-[03]]', 0, None, u'zero', 1, -1, 3, -3, u''] ,
                [u'[09]-[[01]-[04]]', 0, None, u'zero', 1, -1, 2, 4, u''] ,
                [u'[09]-[[01]-[05]]', 0, None, u'zero', 1, -1, 5, -5, u''] ,
                [u'[09]-[[01]-[06]]', 0, None, u'zero', 1, -1, 5, -5, u''] ,
                [u'[09]-[[01]-[07]]', 0, None, u'zero', 1, -1, 0, None, u''] ,
                [u'[09]-[[01]-[08]]', 0, None, u'zero', 1, -1, None, None, u''] ,
                [u'[09]-[[01]-[09]]', 0, None, u'zero', 1, -1, None, 0, u''] ,
                [u'[09]-[[02]-[01]]', 0, None, u'zero', 2, 2, 1, -1, u''] ,
                [u'[09]-[[02]-[02]]', 0, None, u'zero', 2, 2, 2, 2, u''] ,
                [u'[09]-[[02]-[03]]', 0, None, u'zero', 2, 2, 3, -3, u''] ,
                [u'[09]-[[02]-[04]]', 0, None, u'zero', 2, 2, 2, 4, u''] ,
                [u'[09]-[[02]-[05]]', 0, None, u'zero', 2, 2, 5, -5, u''] ,
                [u'[09]-[[02]-[06]]', 0, None, u'zero', 2, 2, 5, -5, u''] ,
                [u'[09]-[[02]-[07]]', 0, None, u'zero', 2, 2, 0, None, u''] ,
                [u'[09]-[[02]-[08]]', 0, None, u'zero', 2, 2, None, None, u''] ,
                [u'[09]-[[02]-[09]]', 0, None, u'zero', 2, 2, None, 0, u''] ,
                [u'[09]-[[03]-[01]]', 0, None, u'zero', 3, -3, 1, -1, u''] ,
                [u'[09]-[[03]-[02]]', 0, None, u'zero', 3, -3, 2, 2, u''] ,
                [u'[09]-[[03]-[03]]', 0, None, u'zero', 3, -3, 3, -3, u''] ,
                [u'[09]-[[03]-[04]]', 0, None, u'zero', 3, -3, 2, 4, u''] ,
                [u'[09]-[[03]-[05]]', 0, None, u'zero', 3, -3, 5, -5, u''] ,
                [u'[09]-[[03]-[06]]', 0, None, u'zero', 3, -3, 5, -5, u''] ,
                [u'[09]-[[03]-[07]]', 0, None, u'zero', 3, -3, 0, None, u''] ,
                [u'[09]-[[03]-[08]]', 0, None, u'zero', 3, -3, None, None, u''] ,
                [u'[09]-[[03]-[09]]', 0, None, u'zero', 3, -3, None, 0, u''] ,
                [u'[09]-[[04]-[01]]', 0, None, u'zero', 2, 4, 1, -1, u''] ,
                [u'[09]-[[04]-[02]]', 0, None, u'zero', 2, 4, 2, 2, u''] ,
                [u'[09]-[[04]-[03]]', 0, None, u'zero', 2, 4, 3, -3, u''] ,
                [u'[09]-[[04]-[04]]', 0, None, u'zero', 2, 4, 2, 4, u''] ,
                [u'[09]-[[04]-[05]]', 0, None, u'zero', 2, 4, 5, -5, u''] ,
                [u'[09]-[[04]-[06]]', 0, None, u'zero', 2, 4, 5, -5, u''] ,
                [u'[09]-[[04]-[07]]', 0, None, u'zero', 2, 4, 0, None, u''] ,
                [u'[09]-[[04]-[08]]', 0, None, u'zero', 2, 4, None, None, u''] ,
                [u'[09]-[[04]-[09]]', 0, None, u'zero', 2, 4, None, 0, u''] ,
                [u'[09]-[[05]-[01]]', 0, None, u'zero', 5, -5, 1, -1, u''] ,
                [u'[09]-[[05]-[02]]', 0, None, u'zero', 5, -5, 2, 2, u''] ,
                [u'[09]-[[05]-[03]]', 0, None, u'zero', 5, -5, 3, -3, u''] ,
                [u'[09]-[[05]-[04]]', 0, None, u'zero', 5, -5, 2, 4, u''] ,
                [u'[09]-[[05]-[05]]', 0, None, u'zero', 5, -5, 5, -5, u''] ,
                [u'[09]-[[05]-[06]]', 0, None, u'zero', 5, -5, 5, -5, u''] ,
                [u'[09]-[[05]-[07]]', 0, None, u'zero', 5, -5, 0, None, u''] ,
                [u'[09]-[[05]-[08]]', 0, None, u'zero', 5, -5, None, None, u''] ,
                [u'[09]-[[05]-[09]]', 0, None, u'zero', 5, -5, None, 0, u''] ,
                [u'[09]-[[06]-[01]]', 0, None, u'zero', 5, -5, 1, -1, u''] ,
                [u'[09]-[[06]-[02]]', 0, None, u'zero', 5, -5, 2, 2, u''] ,
                [u'[09]-[[06]-[03]]', 0, None, u'zero', 5, -5, 3, -3, u''] ,
                [u'[09]-[[06]-[04]]', 0, None, u'zero', 5, -5, 2, 4, u''] ,
                [u'[09]-[[06]-[05]]', 0, None, u'zero', 5, -5, 5, -5, u''] ,
                [u'[09]-[[06]-[06]]', 0, None, u'zero', 5, -5, 5, -5, u''] ,
                [u'[09]-[[06]-[07]]', 0, None, u'zero', 5, -5, 0, None, u''] ,
                [u'[09]-[[06]-[08]]', 0, None, u'zero', 5, -5, None, None, u''] ,
                [u'[09]-[[06]-[09]]', 0, None, u'zero', 5, -5, None, 0, u''] ,
                [u'[09]-[[07]-[01]]', 0, None, u'zero', 0, None, 1, -1, u''] ,
                [u'[09]-[[07]-[02]]', 0, None, u'zero', 0, None, 2, 2, u''] ,
                [u'[09]-[[07]-[03]]', 0, None, u'zero', 0, None, 3, -3, u''] ,
                [u'[09]-[[07]-[04]]', 0, None, u'zero', 0, None, 2, 4, u''] ,
                [u'[09]-[[07]-[05]]', 0, None, u'zero', 0, None, 5, -5, u''] ,
                [u'[09]-[[07]-[06]]', 0, None, u'zero', 0, None, 5, -5, u''] ,
                [u'[09]-[[07]-[07]]', 0, None, u'zero', 0, None, 0, None, u''] ,
                [u'[09]-[[07]-[08]]', 0, None, u'zero', 0, None, None, None, u''] ,
                [u'[09]-[[07]-[09]]', 0, None, u'zero', 0, None, None, 0, u''] ,
                [u'[09]-[[08]-[01]]', 0, None, u'zero', None, None, 1, -1, u''] ,
                [u'[09]-[[08]-[02]]', 0, None, u'zero', None, None, 2, 2, u''] ,
                [u'[09]-[[08]-[03]]', 0, None, u'zero', None, None, 3, -3, u''] ,
                [u'[09]-[[08]-[04]]', 0, None, u'zero', None, None, 2, 4, u''] ,
                [u'[09]-[[08]-[05]]', 0, None, u'zero', None, None, 5, -5, u''] ,
                [u'[09]-[[08]-[06]]', 0, None, u'zero', None, None, 5, -5, u''] ,
                [u'[09]-[[08]-[07]]', 0, None, u'zero', None, None, 0, None, u''] ,
                [u'[09]-[[08]-[08]]', 0, None, u'zero', None, None, None, None, u''] ,
                [u'[09]-[[08]-[09]]', 0, None, u'zero', None, None, None, 0, u''] ,
                [u'[09]-[[09]-[01]]', 0, None, u'zero', None, 0, 1, -1, u''] ,
                [u'[09]-[[09]-[02]]', 0, None, u'zero', None, 0, 2, 2, u''] ,
                [u'[09]-[[09]-[03]]', 0, None, u'zero', None, 0, 3, -3, u''] ,
                [u'[09]-[[09]-[04]]', 0, None, u'zero', None, 0, 2, 4, u''] ,
                [u'[09]-[[09]-[05]]', 0, None, u'zero', None, 0, 5, -5, u''] ,
                [u'[09]-[[09]-[06]]', 0, None, u'zero', None, 0, 5, -5, u''] ,
                [u'[09]-[[09]-[07]]', 0, None, u'zero', None, 0, 0, None, u''] ,
                [u'[09]-[[09]-[08]]', 0, None, u'zero', None, 0, None, None, u''] ,
                [u'[09]-[[09]-[09]]', 0, None, u'zero', None, 0, None, 0, u''] ,
                [u'[10]-[[01]-[01]]', None, None, u'null', 1, -1, 1, -1, u''] ,
                [u'[10]-[[01]-[02]]', None, None, u'null', 1, -1, 2, 2, u''] ,
                [u'[10]-[[01]-[03]]', None, None, u'null', 1, -1, 3, -3, u''] ,
                [u'[10]-[[01]-[04]]', None, None, u'null', 1, -1, 2, 4, u''] ,
                [u'[10]-[[01]-[05]]', None, None, u'null', 1, -1, 5, -5, u''] ,
                [u'[10]-[[01]-[06]]', None, None, u'null', 1, -1, 5, -5, u''] ,
                [u'[10]-[[01]-[07]]', None, None, u'null', 1, -1, 0, None, u''] ,
                [u'[10]-[[01]-[08]]', None, None, u'null', 1, -1, None, None, u''] ,
                [u'[10]-[[01]-[09]]', None, None, u'null', 1, -1, None, 0, u''] ,
                [u'[10]-[[02]-[01]]', None, None, u'null', 2, 2, 1, -1, u''] ,
                [u'[10]-[[02]-[02]]', None, None, u'null', 2, 2, 2, 2, u''] ,
                [u'[10]-[[02]-[03]]', None, None, u'null', 2, 2, 3, -3, u''] ,
                [u'[10]-[[02]-[04]]', None, None, u'null', 2, 2, 2, 4, u''] ,
                [u'[10]-[[02]-[05]]', None, None, u'null', 2, 2, 5, -5, u''] ,
                [u'[10]-[[02]-[06]]', None, None, u'null', 2, 2, 5, -5, u''] ,
                [u'[10]-[[02]-[07]]', None, None, u'null', 2, 2, 0, None, u''] ,
                [u'[10]-[[02]-[08]]', None, None, u'null', 2, 2, None, None, u''] ,
                [u'[10]-[[02]-[09]]', None, None, u'null', 2, 2, None, 0, u''] ,
                [u'[10]-[[03]-[01]]', None, None, u'null', 3, -3, 1, -1, u''] ,
                [u'[10]-[[03]-[02]]', None, None, u'null', 3, -3, 2, 2, u''] ,
                [u'[10]-[[03]-[03]]', None, None, u'null', 3, -3, 3, -3, u''] ,
                [u'[10]-[[03]-[04]]', None, None, u'null', 3, -3, 2, 4, u''] ,
                [u'[10]-[[03]-[05]]', None, None, u'null', 3, -3, 5, -5, u''] ,
                [u'[10]-[[03]-[06]]', None, None, u'null', 3, -3, 5, -5, u''] ,
                [u'[10]-[[03]-[07]]', None, None, u'null', 3, -3, 0, None, u''] ,
                [u'[10]-[[03]-[08]]', None, None, u'null', 3, -3, None, None, u''] ,
                [u'[10]-[[03]-[09]]', None, None, u'null', 3, -3, None, 0, u''] ,
                [u'[10]-[[04]-[01]]', None, None, u'null', 2, 4, 1, -1, u''] ,
                [u'[10]-[[04]-[02]]', None, None, u'null', 2, 4, 2, 2, u''] ,
                [u'[10]-[[04]-[03]]', None, None, u'null', 2, 4, 3, -3, u''] ,
                [u'[10]-[[04]-[04]]', None, None, u'null', 2, 4, 2, 4, u''] ,
                [u'[10]-[[04]-[05]]', None, None, u'null', 2, 4, 5, -5, u''] ,
                [u'[10]-[[04]-[06]]', None, None, u'null', 2, 4, 5, -5, u''] ,
                [u'[10]-[[04]-[07]]', None, None, u'null', 2, 4, 0, None, u''] ,
                [u'[10]-[[04]-[08]]', None, None, u'null', 2, 4, None, None, u''] ,
                [u'[10]-[[04]-[09]]', None, None, u'null', 2, 4, None, 0, u''] ,
                [u'[10]-[[05]-[01]]', None, None, u'null', 5, -5, 1, -1, u''] ,
                [u'[10]-[[05]-[02]]', None, None, u'null', 5, -5, 2, 2, u''] ,
                [u'[10]-[[05]-[03]]', None, None, u'null', 5, -5, 3, -3, u''] ,
                [u'[10]-[[05]-[04]]', None, None, u'null', 5, -5, 2, 4, u''] ,
                [u'[10]-[[05]-[05]]', None, None, u'null', 5, -5, 5, -5, u''] ,
                [u'[10]-[[05]-[06]]', None, None, u'null', 5, -5, 5, -5, u''] ,
                [u'[10]-[[05]-[07]]', None, None, u'null', 5, -5, 0, None, u''] ,
                [u'[10]-[[05]-[08]]', None, None, u'null', 5, -5, None, None, u''] ,
                [u'[10]-[[05]-[09]]', None, None, u'null', 5, -5, None, 0, u''] ,
                [u'[10]-[[06]-[01]]', None, None, u'null', 5, -5, 1, -1, u''] ,
                [u'[10]-[[06]-[02]]', None, None, u'null', 5, -5, 2, 2, u''] ,
                [u'[10]-[[06]-[03]]', None, None, u'null', 5, -5, 3, -3, u''] ,
                [u'[10]-[[06]-[04]]', None, None, u'null', 5, -5, 2, 4, u''] ,
                [u'[10]-[[06]-[05]]', None, None, u'null', 5, -5, 5, -5, u''] ,
                [u'[10]-[[06]-[06]]', None, None, u'null', 5, -5, 5, -5, u''] ,
                [u'[10]-[[06]-[07]]', None, None, u'null', 5, -5, 0, None, u''] ,
                [u'[10]-[[06]-[08]]', None, None, u'null', 5, -5, None, None, u''] ,
                [u'[10]-[[06]-[09]]', None, None, u'null', 5, -5, None, 0, u''] ,
                [u'[10]-[[07]-[01]]', None, None, u'null', 0, None, 1, -1, u''] ,
                [u'[10]-[[07]-[02]]', None, None, u'null', 0, None, 2, 2, u''] ,
                [u'[10]-[[07]-[03]]', None, None, u'null', 0, None, 3, -3, u''] ,
                [u'[10]-[[07]-[04]]', None, None, u'null', 0, None, 2, 4, u''] ,
                [u'[10]-[[07]-[05]]', None, None, u'null', 0, None, 5, -5, u''] ,
                [u'[10]-[[07]-[06]]', None, None, u'null', 0, None, 5, -5, u''] ,
                [u'[10]-[[07]-[07]]', None, None, u'null', 0, None, 0, None, u''] ,
                [u'[10]-[[07]-[08]]', None, None, u'null', 0, None, None, None, u''] ,
                [u'[10]-[[07]-[09]]', None, None, u'null', 0, None, None, 0, u''] ,
                [u'[10]-[[08]-[01]]', None, None, u'null', None, None, 1, -1, u''] ,
                [u'[10]-[[08]-[02]]', None, None, u'null', None, None, 2, 2, u''] ,
                [u'[10]-[[08]-[03]]', None, None, u'null', None, None, 3, -3, u''] ,
                [u'[10]-[[08]-[04]]', None, None, u'null', None, None, 2, 4, u''] ,
                [u'[10]-[[08]-[05]]', None, None, u'null', None, None, 5, -5, u''] ,
                [u'[10]-[[08]-[06]]', None, None, u'null', None, None, 5, -5, u''] ,
                [u'[10]-[[08]-[07]]', None, None, u'null', None, None, 0, None, u''] ,
                [u'[10]-[[08]-[08]]', None, None, u'null', None, None, None, None, u''] ,
                [u'[10]-[[08]-[09]]', None, None, u'null', None, None, None, 0, u''] ,
                [u'[10]-[[09]-[01]]', None, None, u'null', None, 0, 1, -1, u''] ,
                [u'[10]-[[09]-[02]]', None, None, u'null', None, 0, 2, 2, u''] ,
                [u'[10]-[[09]-[03]]', None, None, u'null', None, 0, 3, -3, u''] ,
                [u'[10]-[[09]-[04]]', None, None, u'null', None, 0, 2, 4, u''] ,
                [u'[10]-[[09]-[05]]', None, None, u'null', None, 0, 5, -5, u''] ,
                [u'[10]-[[09]-[06]]', None, None, u'null', None, 0, 5, -5, u''] ,
                [u'[10]-[[09]-[07]]', None, None, u'null', None, 0, 0, None, u''] ,
                [u'[10]-[[09]-[08]]', None, None, u'null', None, 0, None, None, u''] ,
                [u'[10]-[[09]-[09]]', None, None, u'null', None, 0, None, 0, u''] ,
                [u'[11]-[[01]-[01]]', None, 0, u'zero', 1, -1, 1, -1, u''] ,
                [u'[11]-[[01]-[02]]', None, 0, u'zero', 1, -1, 2, 2, u''] ,
                [u'[11]-[[01]-[03]]', None, 0, u'zero', 1, -1, 3, -3, u''] ,
                [u'[11]-[[01]-[04]]', None, 0, u'zero', 1, -1, 2, 4, u''] ,
                [u'[11]-[[01]-[05]]', None, 0, u'zero', 1, -1, 5, -5, u''] ,
                [u'[11]-[[01]-[06]]', None, 0, u'zero', 1, -1, 5, -5, u''] ,
                [u'[11]-[[01]-[07]]', None, 0, u'zero', 1, -1, 0, None, u''] ,
                [u'[11]-[[01]-[08]]', None, 0, u'zero', 1, -1, None, None, u''] ,
                [u'[11]-[[01]-[09]]', None, 0, u'zero', 1, -1, None, 0, u''] ,
                [u'[11]-[[02]-[01]]', None, 0, u'zero', 2, 2, 1, -1, u''] ,
                [u'[11]-[[02]-[02]]', None, 0, u'zero', 2, 2, 2, 2, u''] ,
                [u'[11]-[[02]-[03]]', None, 0, u'zero', 2, 2, 3, -3, u''] ,
                [u'[11]-[[02]-[04]]', None, 0, u'zero', 2, 2, 2, 4, u''] ,
                [u'[11]-[[02]-[05]]', None, 0, u'zero', 2, 2, 5, -5, u''] ,
                [u'[11]-[[02]-[06]]', None, 0, u'zero', 2, 2, 5, -5, u''] ,
                [u'[11]-[[02]-[07]]', None, 0, u'zero', 2, 2, 0, None, u''] ,
                [u'[11]-[[02]-[08]]', None, 0, u'zero', 2, 2, None, None, u''] ,
                [u'[11]-[[02]-[09]]', None, 0, u'zero', 2, 2, None, 0, u''] ,
                [u'[11]-[[03]-[01]]', None, 0, u'zero', 3, -3, 1, -1, u''] ,
                [u'[11]-[[03]-[02]]', None, 0, u'zero', 3, -3, 2, 2, u''] ,
                [u'[11]-[[03]-[03]]', None, 0, u'zero', 3, -3, 3, -3, u''] ,
                [u'[11]-[[03]-[04]]', None, 0, u'zero', 3, -3, 2, 4, u''] ,
                [u'[11]-[[03]-[05]]', None, 0, u'zero', 3, -3, 5, -5, u''] ,
                [u'[11]-[[03]-[06]]', None, 0, u'zero', 3, -3, 5, -5, u''] ,
                [u'[11]-[[03]-[07]]', None, 0, u'zero', 3, -3, 0, None, u''] ,
                [u'[11]-[[03]-[08]]', None, 0, u'zero', 3, -3, None, None, u''] ,
                [u'[11]-[[03]-[09]]', None, 0, u'zero', 3, -3, None, 0, u''] ,
                [u'[11]-[[04]-[01]]', None, 0, u'zero', 2, 4, 1, -1, u''] ,
                [u'[11]-[[04]-[02]]', None, 0, u'zero', 2, 4, 2, 2, u''] ,
                [u'[11]-[[04]-[03]]', None, 0, u'zero', 2, 4, 3, -3, u''] ,
                [u'[11]-[[04]-[04]]', None, 0, u'zero', 2, 4, 2, 4, u''] ,
                [u'[11]-[[04]-[05]]', None, 0, u'zero', 2, 4, 5, -5, u''] ,
                [u'[11]-[[04]-[06]]', None, 0, u'zero', 2, 4, 5, -5, u''] ,
                [u'[11]-[[04]-[07]]', None, 0, u'zero', 2, 4, 0, None, u''] ,
                [u'[11]-[[04]-[08]]', None, 0, u'zero', 2, 4, None, None, u''] ,
                [u'[11]-[[04]-[09]]', None, 0, u'zero', 2, 4, None, 0, u''] ,
                [u'[11]-[[05]-[01]]', None, 0, u'zero', 5, -5, 1, -1, u''] ,
                [u'[11]-[[05]-[02]]', None, 0, u'zero', 5, -5, 2, 2, u''] ,
                [u'[11]-[[05]-[03]]', None, 0, u'zero', 5, -5, 3, -3, u''] ,
                [u'[11]-[[05]-[04]]', None, 0, u'zero', 5, -5, 2, 4, u''] ,
                [u'[11]-[[05]-[05]]', None, 0, u'zero', 5, -5, 5, -5, u''] ,
                [u'[11]-[[05]-[06]]', None, 0, u'zero', 5, -5, 5, -5, u''] ,
                [u'[11]-[[05]-[07]]', None, 0, u'zero', 5, -5, 0, None, u''] ,
                [u'[11]-[[05]-[08]]', None, 0, u'zero', 5, -5, None, None, u''] ,
                [u'[11]-[[05]-[09]]', None, 0, u'zero', 5, -5, None, 0, u''] ,
                [u'[11]-[[06]-[01]]', None, 0, u'zero', 5, -5, 1, -1, u''] ,
                [u'[11]-[[06]-[02]]', None, 0, u'zero', 5, -5, 2, 2, u''] ,
                [u'[11]-[[06]-[03]]', None, 0, u'zero', 5, -5, 3, -3, u''] ,
                [u'[11]-[[06]-[04]]', None, 0, u'zero', 5, -5, 2, 4, u''] ,
                [u'[11]-[[06]-[05]]', None, 0, u'zero', 5, -5, 5, -5, u''] ,
                [u'[11]-[[06]-[06]]', None, 0, u'zero', 5, -5, 5, -5, u''] ,
                [u'[11]-[[06]-[07]]', None, 0, u'zero', 5, -5, 0, None, u''] ,
                [u'[11]-[[06]-[08]]', None, 0, u'zero', 5, -5, None, None, u''] ,
                [u'[11]-[[06]-[09]]', None, 0, u'zero', 5, -5, None, 0, u''] ,
                [u'[11]-[[07]-[01]]', None, 0, u'zero', 0, None, 1, -1, u''] ,
                [u'[11]-[[07]-[02]]', None, 0, u'zero', 0, None, 2, 2, u''] ,
                [u'[11]-[[07]-[03]]', None, 0, u'zero', 0, None, 3, -3, u''] ,
                [u'[11]-[[07]-[04]]', None, 0, u'zero', 0, None, 2, 4, u''] ,
                [u'[11]-[[07]-[05]]', None, 0, u'zero', 0, None, 5, -5, u''] ,
                [u'[11]-[[07]-[06]]', None, 0, u'zero', 0, None, 5, -5, u''] ,
                [u'[11]-[[07]-[07]]', None, 0, u'zero', 0, None, 0, None, u''] ,
                [u'[11]-[[07]-[08]]', None, 0, u'zero', 0, None, None, None, u''] ,
                [u'[11]-[[07]-[09]]', None, 0, u'zero', 0, None, None, 0, u''] ,
                [u'[11]-[[08]-[01]]', None, 0, u'zero', None, None, 1, -1, u''] ,
                [u'[11]-[[08]-[02]]', None, 0, u'zero', None, None, 2, 2, u''] ,
                [u'[11]-[[08]-[03]]', None, 0, u'zero', None, None, 3, -3, u''] ,
                [u'[11]-[[08]-[04]]', None, 0, u'zero', None, None, 2, 4, u''] ,
                [u'[11]-[[08]-[05]]', None, 0, u'zero', None, None, 5, -5, u''] ,
                [u'[11]-[[08]-[06]]', None, 0, u'zero', None, None, 5, -5, u''] ,
                [u'[11]-[[08]-[07]]', None, 0, u'zero', None, None, 0, None, u''] ,
                [u'[11]-[[08]-[08]]', None, 0, u'zero', None, None, None, None, u''] ,
                [u'[11]-[[08]-[09]]', None, 0, u'zero', None, None, None, 0, u''] ,
                [u'[11]-[[09]-[01]]', None, 0, u'zero', None, 0, 1, -1, u''] ,
                [u'[11]-[[09]-[02]]', None, 0, u'zero', None, 0, 2, 2, u''] ,
                [u'[11]-[[09]-[03]]', None, 0, u'zero', None, 0, 3, -3, u''] ,
                [u'[11]-[[09]-[04]]', None, 0, u'zero', None, 0, 2, 4, u''] ,
                [u'[11]-[[09]-[05]]', None, 0, u'zero', None, 0, 5, -5, u''] ,
                [u'[11]-[[09]-[06]]', None, 0, u'zero', None, 0, 5, -5, u''] ,
                [u'[11]-[[09]-[07]]', None, 0, u'zero', None, 0, 0, None, u''] ,
                [u'[11]-[[09]-[08]]', None, 0, u'zero', None, 0, None, None, u''] ,
                [u'[11]-[[09]-[09]]', None, 0, u'zero', None, 0, None, 0, u'']
            ]
        )

    def test_equi_join(self):
        res = mldb.query("""
            SELECT '' AS "xxx", * FROM J1_TBL INNER JOIN J2_TBL ON J1_TBL.i = J2_TBL.i ORDER BY rowName()
        """)

        self.assertTableResultEquals(res,
            [
               [u'_rowName', u'J1_TBL.i', u'J1_TBL.j', u'J1_TBL.t', u'J2_TBL.i', u'J2_TBL.k', u'xxx'] ,
                [u'[01]-[01]', 1, 4, u'one', 1, -1, u''] ,
                [u'[02]-[02]', 2, 3, u'two', 2, 2, u''] ,
                [u'[02]-[04]', 2, 3, u'two', 2, 4, u''] ,
                [u'[03]-[03]', 3, 2, u'three', 3, -3, u''] ,
                [u'[05]-[05]', 5, 0, u'five', 5, -5, u''] ,
                [u'[05]-[06]', 5, 0, u'five', 5, -5, u''] ,
                [u'[09]-[07]', 0, None, u'zero', 0, None, u'']
            ]
        )

    # MLDB-1664
    def test_non_equi_join(self):
        res = mldb.query("""
            SELECT '' AS "xxx", * FROM J1_TBL JOIN J2_TBL ON J1_TBL.i <= J2_TBL.k ORDER BY rowName()
        """)

        self.assertTableResultEquals(res,
            [
                [u'_rowName', u'J1_TBL.i', u'J1_TBL.j', u'J1_TBL.t', u'J2_TBL.i', u'J2_TBL.k', u'xxx'] ,
                [u'[01]-[02]', 1, 4, u'one', 2, 2, u''] ,
                [u'[01]-[04]', 1, 4, u'one', 2, 4, u''] ,
                [u'[02]-[02]', 2, 3, u'two', 2, 2, u''] ,
                [u'[02]-[04]', 2, 3, u'two', 2, 4, u''] ,
                [u'[03]-[04]', 3, 2, u'three', 2, 4, u''] ,
                [u'[04]-[04]', 4, 1, u'four', 2, 4, u''] ,
                [u'[09]-[02]', 0, None, u'zero', 2, 2, u''] ,
                [u'[09]-[04]', 0, None, u'zero', 2, 4, u''] ,
                [u'[09]-[09]', 0, None, u'zero', None, 0, u'']
            ]
        )

        res = mldb.query("""
            SELECT J1_TBL.i, J2_TBL.k FROM J1_TBL JOIN J2_TBL ON J1_TBL.i < J2_TBL.k ORDER BY rowName()
        """)

        self.assertTableResultEquals(res,
            [
                [u'_rowName', u'J1_TBL.i', 'J2_TBL.k'] ,
                [u'[01]-[02]', 1, 2] ,
                [u'[01]-[04]', 1, 4] ,
                [u'[02]-[04]', 2, 4] ,
                [u'[03]-[04]', 3, 4] ,
                [u'[09]-[02]', 0, 2] ,
                [u'[09]-[04]', 0, 4]
            ]
        )

        res = mldb.query("""
            SELECT J1_TBL.i, J2_TBL.k FROM J1_TBL JOIN J2_TBL ON J1_TBL.i > J2_TBL.k ORDER BY rowName() LIMIT 13
        """)

        self.assertTableResultEquals(res,
            [
                [u'_rowName', u'J1_TBL.i', u'J2_TBL.k'] ,
                [u'[01]-[01]', 1, -1] ,
                [u'[01]-[03]', 1, -3] ,
                [u'[01]-[05]', 1, -5] ,
                [u'[01]-[06]', 1, -5] ,
                [u'[01]-[09]', 1, 0] ,
                [u'[02]-[01]', 2, -1] ,
                [u'[02]-[03]', 2, -3] ,
                [u'[02]-[05]', 2, -5] ,
                [u'[02]-[06]', 2, -5] ,
                [u'[02]-[09]', 2, 0] ,
                [u'[03]-[01]', 3, -1] ,
                [u'[03]-[02]', 3, 2] ,
                [u'[03]-[03]', 3, -3]
            ]
        )

        res = mldb.query("""
            SELECT J1_TBL.i, J2_TBL.k FROM J1_TBL JOIN J2_TBL ON
            J1_TBL.i = (-J2_TBL.k) + 3 ORDER BY rowName()
        """)

        self.assertTableResultEquals(res,
            [
                [u'_rowName', u'J1_TBL.i', u'J2_TBL.k'] ,
                [u'[01]-[02]', 1, 2] ,
                [u'[03]-[09]', 3, 0] ,
                [u'[04]-[01]', 4, -1] ,
                [u'[06]-[03]', 6, -3] ,
                [u'[08]-[05]', 8, -5] ,
                [u'[08]-[06]', 8, -5]
            ]
        )

        res = mldb.query("""
            SELECT J1_TBL.i, J2_TBL.k FROM J1_TBL JOIN J2_TBL ON
            J1_TBL.i < J2_TBL.k AND J1_TBL.i = (-J2_TBL.k) + 3 ORDER BY rowName()
        """)

        self.assertTableResultEquals(res,
            [
                [u'_rowName', u'J1_TBL.i', u'J2_TBL.k'] ,
                [u'[01]-[02]', 1, 2]
            ]
        )

        res = mldb.query("""
            SELECT J1_TBL.i, J2_TBL.k, J2_TBL.i FROM J1_TBL JOIN J2_TBL ON
            J1_TBL.i BETWEEN J2_TBL.k AND J2_TBL.i ORDER BY rowName()
        """)
        self.assertTableResultEquals(res,
            [
                [u'_rowName', u'J1_TBL.i', u'J2_TBL.i', u'J2_TBL.k'] ,
                [u'[01]-[01]', 1, 1, -1] ,
                [u'[01]-[03]', 1, 3, -3] ,
                [u'[01]-[05]', 1, 5, -5] ,
                [u'[01]-[06]', 1, 5, -5] ,
                [u'[02]-[02]', 2, 2,  2] ,
                [u'[02]-[03]', 2, 3, -3] ,
                [u'[02]-[05]', 2, 5, -5] ,
                [u'[02]-[06]', 2, 5, -5] ,
                [u'[03]-[03]', 3, 3, -3] ,
                [u'[03]-[05]', 3, 5, -5] ,
                [u'[03]-[06]', 3, 5, -5] ,
                [u'[04]-[05]', 4, 5, -5] ,
                [u'[04]-[06]', 4, 5, -5] ,
                [u'[05]-[05]', 5, 5, -5] ,
                [u'[05]-[06]', 5, 5, -5] ,
                [u'[09]-[01]', 0, 1, -1] ,
                [u'[09]-[03]', 0, 3, -3] ,
                [u'[09]-[05]', 0, 5, -5] ,
                [u'[09]-[06]', 0, 5, -5]
            ]
        )

    # MLDB-1664
    def test_non_equi_join_with_function(self):
        res = mldb.query("""
            SELECT  J1_TBL.i, J2_TBL.k FROM J1_TBL JOIN J2_TBL ON J1_TBL.i < abs(J2_TBL.k) ORDER BY rowName()
        """)
        self.assertTableResultEquals(res,
            [
              [u'_rowName', u'J1_TBL.i', u'J2_TBL.k'] ,
                [u'[01]-[02]', 1, 2] ,
                [u'[01]-[03]', 1, -3] ,
                [u'[01]-[04]', 1, 4] ,
                [u'[01]-[05]', 1, -5] ,
                [u'[01]-[06]', 1, -5] ,
                [u'[02]-[03]', 2, -3] ,
                [u'[02]-[04]', 2, 4] ,
                [u'[02]-[05]', 2, -5] ,
                [u'[02]-[06]', 2, -5] ,
                [u'[03]-[04]', 3, 4] ,
                [u'[03]-[05]', 3, -5] ,
                [u'[03]-[06]', 3, -5] ,
                [u'[04]-[05]', 4, -5] ,
                [u'[04]-[06]', 4, -5] ,
                [u'[09]-[01]', 0, -1] ,
                [u'[09]-[02]', 0, 2] ,
                [u'[09]-[03]', 0, -3] ,
                [u'[09]-[04]', 0, 4] ,
                [u'[09]-[05]', 0, -5] ,
                [u'[09]-[06]', 0, -5]
            ]
        )

        res = mldb.query("""
            SELECT  J1_TBL.t, J2_TBL.k FROM J1_TBL JOIN J2_TBL
            ON regex_search(J1_TBL.t, 'three') and J2_TBL.k > 3
        """)
        self.assertTableResultEquals(res,
            [
                [u'_rowName', u'J1_TBL.t', u'J2_TBL.k'] ,
                [u'[03]-[04]', 'three', 4]
            ]
        )

    # MLDB-1664 and MLDB-1670
    def test_disguised_equi_join(self):
        res = mldb.query("""
            SELECT J1_TBL.t, J2_TBL.k FROM J1_TBL JOIN J2_TBL
            ON J1_TBL.i + J2_TBL.k = 3 ORDER BY rowName()
        """)
        pprint(res)
        self.assertTableResultEquals(res,
            [
                [u'_rowName', u'J1_TBL.t', u'J2_TBL.k'] ,
                [u'[01]-[02]', u'one', 2] ,
                [u'[03]-[09]', u'three', 0] ,
                [u'[04]-[01]', u'four', -1] ,
                [u'[06]-[03]', u'six', -3] ,
                [u'[08]-[05]', u'eight', -5] ,
                [u'[08]-[06]', u'eight', -5]
            ]
        )

    def test_precendence_in_on_condition_MLDBFB_503(self):
        res1 = mldb.query("""
            SELECT J1_TBL.i, J2_TBL.k FROM J1_TBL JOIN J2_TBL ON
            J1_TBL.i = (-J2_TBL.k) + 3 ORDER BY rowName()
        """)
        self.assertTableResultEquals(res1,
            [
                [u'_rowName', u'J1_TBL.i', u'J2_TBL.k'] ,
                [u'[01]-[02]', 1,  2] ,
                [u'[03]-[09]', 3,  0] ,
                [u'[04]-[01]', 4, -1] ,
                [u'[06]-[03]', 6, -3] ,
                [u'[08]-[05]', 8, -5] ,
                [u'[08]-[06]', 8, -5]
            ]
        )

        res2 = mldb.query("""
            SELECT J1_TBL.i, J2_TBL.k FROM J1_TBL JOIN J2_TBL ON
            J1_TBL.i = -J2_TBL.k + 3 ORDER BY rowName()
        """)

        pprint(res1)
        # output should look as above
        self.assertTableResultEquals(res1, res2)

    def test_left_outer_join(self):
        res = mldb.query("""
            SELECT '' AS "xxx", *
            FROM J1_TBL LEFT OUTER JOIN J2_TBL ON J1_TBL.i = J2_TBL.i
            ORDER BY J1_TBL.i, J2_TBL.k, J1_TBL.t
        """)
        pprint(res)
        self.assertTableResultEquals(res,
            [
                [u'_rowName', u'J1_TBL.t', u'xxx', u'J1_TBL.j', u'J1_TBL.i', u'J2_TBL.i', u'J2_TBL.k'] ,
                [u'[10]-[]', u'null', u'', None, None, None, None] ,
                [u'[11]-[]', u'zero', u'', 0, None, None, None] ,
                [u'[09]-[07]', u'zero', u'', None, 0, 0, None] ,
                [u'[01]-[01]', u'one', u'', 4, 1, 1, -1] ,
                [u'[02]-[02]', u'two', u'', 3, 2, 2, 2] ,
                [u'[02]-[04]', u'two', u'', 3, 2, 2, 4] ,
                [u'[03]-[03]', u'three', u'', 2, 3, 3, -3] ,
                [u'[04]-[]', u'four', u'', 1, 4, None, None] ,
                [u'[05]-[06]', u'five', u'', 0, 5, 5, -5] ,
                [u'[05]-[05]', u'five', u'', 0, 5, 5, -5] ,
                [u'[06]-[]', u'six', u'', 6, 6, None, None] ,
                [u'[07]-[]', u'seven', u'', 7, 7, None, None] ,
                [u'[08]-[]', u'eight', u'', 8, 8, None, None]
            ]
        )

    # MLDB-1672
    def test_right_outer_join(self):
        res = mldb.query("""
            SELECT '' AS "xxx", *
        FROM J1_TBL RIGHT OUTER JOIN J2_TBL ON J1_TBL.i = J2_TBL.i
        """)

        pprint(res)
        self.assertTableResultEquals(res,
            [
                [u'_rowName', u'xxx', u'J2_TBL.k', u'J1_TBL.i', u'J1_TBL.t', u'J2_TBL.i', u'J1_TBL.j'] ,
                [u'[]-[08]', u'', None, None, None, None, None] ,
                [u'[]-[09]', u'', 0, None, None, None, None] ,
                [u'[09]-[07]', u'', None, 0, u'zero', 0, None] ,
                [u'[01]-[01]', u'', -1, 1, u'one', 1, 4] ,
                [u'[02]-[02]', u'', 2, 2, u'two', 2, 3] ,
                [u'[02]-[04]', u'', 4, 2, u'two', 2, 3] ,
                [u'[03]-[03]', u'', -3, 3, u'three', 3, 2] ,
                [u'[05]-[05]', u'', -5, 5, u'five', 5, 0] ,
                [u'[05]-[06]', u'', -5, 5, u'five', 5, 0]
            ]
        )

    # MLDB-1672
    def test_full_outer_join(self):
        res = mldb.query("""
            SELECT '' AS "xxx", *
            FROM J1_TBL FULL OUTER JOIN J2_TBL ON J1_TBL.i = J2_TBL.i
            ORDER BY J1_TBL.i, J2_TBL.k, J1_TBL.t
        """)

        pprint(res)
        self.assertTableResultEquals(res,
            [
                [u'_rowName', u'xxx', u'J1_TBL.t', u'J1_TBL.j', u'J2_TBL.k', u'J1_TBL.i', u'J2_TBL.i'] ,
                [u'[]-[08]', u'', None, None, None, None, None] ,
                [u'[10]-[]', u'', u'null', None, None, None, None] ,
                [u'[11]-[]', u'', u'zero', 0, None, None, None] ,
                [u'[]-[09]', u'', None, None, 0, None, None] ,
                [u'[09]-[07]', u'', u'zero', None, None, 0, 0] ,
                [u'[01]-[01]', u'', u'one', 4, -1, 1, 1] ,
                [u'[02]-[02]', u'', u'two', 3, 2, 2, 2] ,
                [u'[02]-[04]', u'', u'two', 3, 4, 2, 2] ,
                [u'[03]-[03]', u'', u'three', 2, -3, 3, 3] ,
                [u'[04]-[]', u'', u'four', 1, None, 4, None] ,
                [u'[05]-[06]', u'', u'five', 0, -5, 5, 5] ,
                [u'[05]-[05]', u'', u'five', 0, -5, 5, 5] ,
                [u'[06]-[]', u'', u'six', 6, None, 6, None] ,
                [u'[07]-[]', u'', u'seven', 7, None, 7, None] ,
                [u'[08]-[]', u'', u'eight', 8, None, 8, None]
            ]
        )


    def test_join_with_where(self):
        res = mldb.query("""
            SELECT '' AS "xxx", *
            FROM J1_TBL LEFT JOIN J2_TBL ON J1_TBL.i = J2_TBL.i WHERE J2_TBL.k = 1
        """)

        pprint(res)
        self.assertTableResultEquals(res,
            [
                [u'_rowName']
            ]
        )

        res = mldb.query("""
            SELECT '' AS "xxx", *
            FROM J1_TBL LEFT JOIN J2_TBL ON J1_TBL.i = J2_TBL.i WHERE J2_TBL.i= 1
        """)

        pprint(res)
        self.assertTableResultEquals(res,
            [
                [u'_rowName', u'J1_TBL.i', u'J1_TBL.j', u'J1_TBL.t', u'J2_TBL.i', u'J2_TBL.k', u'xxx'] ,
                [u'[01]-[01]', 1, 4, u'one', 1, -1, u'']
            ]
        )

    def test_multiway_join(self):
        """
        the name of the row is incorrect
        - [u'[]-[03]', None, None, None, None, u'dd', 33]
        + [u'[]-[]-[03]', None, None, None, None, u'dd', 33]
        """
        res = mldb.query("""
            SELECT * FROM t1 FULL JOIN t2 ON t1.name = t2.name FULL JOIN t3 ON t2.name = t3.name
        """)

        pprint(res)
        self.assertTableResultEquals(res,
            [
                [u'_rowName', u't1.name', u't1.n', u't2.name', u't2.n', u't3.name', u't3.n'] ,
                [u'[01]-[01]-[01]', u'bb', 11, u'bb', 12, u'bb', 13] ,
                [u'[]-[02]-[02]', None, None, u'cc', 22, u'cc', 23] ,
                [u'[]-[]-[03]', None, None, None, None, u'dd', 33] ,
                [u'[]-[03]-[]', None, None, u'ee', 42, None, None]
            ]
        )

        res = mldb.query("""
        select * from x left join y on (x.x1 = y.y1) left join x as xx
        on (x.x1 = xx.x1)
        """)

        pprint(res)
        # number of columns
        self.assertEqual(len(res[0]), 2 + 2 + 2 + 1)


    def test_join_with_subqueries(self):
        res = mldb.query("""
            SELECT * FROM
            (SELECT * FROM t2) AS s2
            INNER JOIN
            (SELECT * FROM t3) AS s3
            ON s2.name = s3.name
        """)

        self.assertTableResultEquals(res,
            [
                [u'_rowName', u's2.name', u's2.n', u's3.name', u's3.n'] ,
                [u'[01]-[01]', u'bb', 12, u'bb', 13] ,
                [u'[02]-[02]', u'cc', 22, u'cc', 23]
            ]
        )


        res = mldb.query("""
            SELECT * FROM
            (SELECT * FROM t2) AS s2
            LEFT JOIN
            (SELECT * FROM t3) AS s3
            ON s2.name = s3.name
        """)

        self.assertTableResultEquals(res,
            [
                [u'_rowName', u's2.name', u's2.n', u's3.name', u's3.n'] ,
                [u'[01]-[01]', u'bb', 12, u'bb', 13] ,
                [u'[02]-[02]', u'cc', 22, u'cc', 23] ,
                [u'[03]-[]', u'ee', 42, None, None]
            ]
        )


        res = mldb.query("""
            SELECT * FROM
            (SELECT * FROM t2) AS s2
            FULL JOIN
            (SELECT * FROM t3) AS s3
            ON s2.name = s3.name
        """)

        self.assertTableResultEquals(res,
            [
                [u'_rowName', u's2.name', u's2.n', u's3.name', u's3.n'] ,
                [u'[01]-[01]', u'bb', 12, u'bb', 13] ,
                [u'[02]-[02]', u'cc', 22, u'cc', 23] ,
                [u'[]-[03]', None, None, u'dd', 33] ,
                [u'[03]-[]', u'ee', 42, None, None]
            ]
        )


    def test_join_with_constant_expression(self):
        res = mldb.query("""
            SELECT * FROM
                (SELECT name, n as s2_n, 2 as s2_2 FROM t2) AS s2
                INNER JOIN
                (SELECT name, n as s3_n, 3 as s3_2 FROM t3) AS s3
        """)

        self.assertTableResultEquals(res,
            [
             [u'_rowName', u's2.name', u's2.s2_2', u's2.s2_n', u's3.name', u's3.s3_2', u's3.s3_n'] ,
                [u'[01]-[01]', u'bb', 2, 12, u'bb', 3, 13] ,
                [u'[01]-[02]', u'bb', 2, 12, u'cc', 3, 23] ,
                [u'[01]-[03]', u'bb', 2, 12, u'dd', 3, 33] ,
                [u'[02]-[01]', u'cc', 2, 22, u'bb', 3, 13] ,
                [u'[02]-[02]', u'cc', 2, 22, u'cc', 3, 23] ,
                [u'[02]-[03]', u'cc', 2, 22, u'dd', 3, 33] ,
                [u'[03]-[01]', u'ee', 2, 42, u'bb', 3, 13] ,
                [u'[03]-[02]', u'ee', 2, 42, u'cc', 3, 23] ,
                [u'[03]-[03]', u'ee', 2, 42, u'dd', 3, 33]
            ]
        )


        res = mldb.query("""
            SELECT * FROM
                (SELECT name, n as s2_n, 2 as s2_2 FROM t2) AS s2
                INNER JOIN
                (SELECT name, n as s3_n, 3 as s3_2 FROM t3) AS s3
                ON s2.name = s3.name
        """)

        self.assertTableResultEquals(res,
            [
                [u'_rowName', u's2.name', u's2.s2_2', u's2.s2_n', u's3.name', u's3.s3_2', u's3.s3_n'] ,
                [u'[01]-[01]', u'bb', 2, 12, u'bb', 3, 13] ,
                [u'[02]-[02]', u'cc', 2, 22, u'cc', 3, 23]
            ]
        )

        res = mldb.query("""
            SELECT * FROM
                (SELECT name, n as s2_n, 2 as s2_2 FROM t2) AS s2
                LEFT JOIN
                (SELECT name, n as s3_n, 3 as s3_2 FROM t3) AS s3
                ON s2.name = s3.name
        """)
        # this is matching Postgresql behaviour
        # constant expression go to null
        self.assertTableResultEquals(res,
            [
                [u'_rowName', u's2.name', u's2.s2_2', u's2.s2_n', u's3.name', u's3.s3_2', u's3.s3_n'] ,
                [u'[01]-[01]', u'bb', 2, 12, u'bb', 3, 13] ,
                [u'[02]-[02]', u'cc', 2, 22, u'cc', 3, 23] ,
                [u'[03]-[]', u'ee', 2, 42, None, None, None]
            ]
        )

        res = mldb.query("""
            SELECT * FROM
                (SELECT name, n as s2_n, 2 as s2_2 FROM t2) AS s2
                FULL JOIN
                (SELECT name, n as s3_n, 3 as s3_2 FROM t3) AS s3
                ON s2.name = s3.name
        """)

        # this is matching Postgresql behaviour
        # constant expression go to null
        self.assertTableResultEquals(res,
            [
                [u'_rowName', u's2.name', u's2.s2_2', u's2.s2_n', u's3.name', u's3.s3_2', u's3.s3_n'] ,
                [u'[01]-[01]', u'bb', 2, 12, u'bb', 3, 13] ,
                [u'[02]-[02]', u'cc', 2, 22, u'cc', 3, 23] ,
                [u'[]-[03]', None, None, None, u'dd', 3, 33] ,
                [u'[03]-[]', u'ee', 2, 42, None, None, None]
            ]
        )

        res = mldb.query("""
        SELECT * FROM
            (SELECT name, n as s1_n, 1 as s1_1 FROM t1) AS s1
            JOIN
            (SELECT name, n as s2_n, 2 as s2_2 FROM t2) AS s2
            ON s1.name = s2.name
            JOIN
            (SELECT name, n as s3_n, 3 as s3_2 FROM t3) AS s3
            ON s2.name = s3.name
        """)

        self.assertTableResultEquals(res,
            [
                [u'_rowName', u's1.name', u's1.s1_1', u's1.s1_n', u's2.name', u's2.s2_2', u's2.s2_n', u's3.name', u's3.s3_2', u's3.s3_n'] ,
                [u'[01]-[01]-[01]', u'bb', 1, 11, u'bb', 2, 12, u'bb', 3, 13]
            ]
        )

        res = mldb.query("""
        SELECT * FROM
            (SELECT name, n as s1_n FROM t1) as s1
            FULL JOIN
            (SELECT * FROM
                (SELECT name, n as s2_n FROM t2) as s2
                FULL JOIN
                (SELECT name, n as s3_n FROM t3) as s3
                ON s2.name = s3.name) as ss2
            ON s1.name = ss2.s2.name
        """)

        self.assertTableResultEquals(res,
            [
                [u'_rowName', u'ss2.s3.name', u'ss2.s3.s3_n', u's1.name', u's1.s1_n', u'ss2.s2.name', u'ss2.s2.s2_n'] ,
                [u'[]-[[]-[03]]', u'dd', 33, None, None, None, None] ,
                [u'[01]-[[01]-[01]]', u'bb', 13, u'bb', 11, u'bb', 12] ,
                [u'[]-[[02]-[02]]', u'cc', 23, None, None, u'cc', 22] ,
                [u'[]-[[03]-[]]', None, None, None, None, u'ee', 42]
            ]
        )

        res = mldb.query("""
        SELECT * FROM
            (SELECT name, n as s1_n FROM t1) as s1
            FULL JOIN
            (SELECT * FROM
                (SELECT name, n as s2_n, 2 as s2_2 FROM t2) as s2
                FULL JOIN
               (SELECT name, n as s3_n FROM t3) as s3
               ON s2.name = s3.name) as ss2
            ON s1.name = ss2.s2.name
        """)

        pprint(res)
        self.assertTableResultEquals(res,
            [
                [u'_rowName', u'ss2.s3.name', u'ss2.s3.s3_n', u's1.name', u's1.s1_n', u'ss2.s2.name', u'ss2.s2.s2_2', u'ss2.s2.s2_n'] ,
                [u'[]-[[]-[03]]', u'dd', 33, None, None, None, None, None] ,
                [u'[01]-[[01]-[01]]', u'bb', 13, u'bb', 11, u'bb', 2, 12] ,
                [u'[]-[[02]-[02]]', u'cc', 23, None, None, u'cc', 2, 22] ,
                [u'[]-[[03]-[]]', None, None, None, None, u'ee', 2, 42]
            ]
        )

    # MLDB-1673
    def test_join_with_constant_expression_failing_on_get_variable(self):
        """
        {"details":{"columnName":"s2.n"},"error":"Get variable without table name with no default table in scope","httpCode":500}
        """

        res = mldb.query("""
            SELECT * FROM
            (SELECT name, n, 2 as s2_2 FROM t2) AS s2
            INNER JOIN
            (SELECT name, n, 3 as s3_2 FROM t3) AS s3
            ON s2.name = s3.name AND s2.n + 1 = s3.n
        """)

        pprint(res)
        self.assertTableResultEquals(res,
            [
                [u'_rowName', u's2.n', u's2.name', u's2.s2_2', u's3.n', u's3.name', u's3.s3_2'] ,
                [u'[01]-[01]', 12, u'bb', 2, 13, u'bb', 3] ,
                [u'[02]-[02]', 22, u'cc', 2, 23, u'cc', 3]
            ]
        )


        res = mldb.query("""
            SELECT * FROM
            (SELECT name, n AS s2_n, 2 as s2_2 FROM t2) AS s2
            INNER JOIN
            (SELECT name, n AS s3_n, 3 as s3_2 FROM t3) AS s3
            ON s2.name = s3.name AND s2.s2_n + 1 = s3.s3_n
        """)

        pprint(res)
        self.assertTableResultEquals(res,
            [
                [u'_rowName', u's2.name', u's2.s2_2', u's2.s2_n', u's3.name', u's3.s3_2', u's3.s3_n'] ,
                [u'[01]-[01]', u'bb', 2, 12, u'bb', 3, 13] ,
                [u'[02]-[02]', u'cc', 2, 22, u'cc', 3, 23]
            ]
        )

    # MLDB-1674
    def test_join_with_constant_expression_failing_on_parsing(self):
        """
        confusing INNER JOIN with IN oeprator
        {"error":"\n        SELECT * FROM\n        (SELECT name, n as s1_n, 1 as s1_1 FROM t1) AS s1\n        INNER JOIN\n        (SELECT name, n as s2_n, 2 as s2_2 FROM t2) AS s2\n        ON s1.name = s2.name\n        INNER JOIN\n        (SELECT name, n as s3_n, 3 as s3_2 FROM t3) AS s3\n        ON s2.name = s3.name\n        :7:11 (' ON s1.name = s2.name\n        IN>>>N<<<ER JOIN\n        (SELECT name, n'): expected whitespace","httpCode":400}
        """
        res = mldb.query("""
        SELECT * FROM
        (SELECT name, n as s1_n, 1 as s1_1 FROM t1) AS s1
        INNER JOIN
        (SELECT name, n as s2_n, 2 as s2_2 FROM t2) AS s2
        ON s1.name = s2.name
        INNER JOIN
        (SELECT name, n as s3_n, 3 as s3_2 FROM t3) AS s3
        ON s2.name = s3.name
        """)

        self.assertTableResultEquals(res,
            [
                [u'_rowName', u's1.name', u's1.s1_1', u's1.s1_n', u's2.name', u's2.s2_2', u's2.s2_n', u's3.name', u's3.s3_2', u's3.s3_n'] ,
                [u'[01]-[01]-[01]', u'bb', 1, 11, u'bb', 2, 12, u'bb', 3, 13]
            ]
        )

    def test_join_with_constant_expression_failing_on_row_name(self):
        """
        - [u'[]-[03]', None, None, None, None, None, None, u'dd', 3, 33]
        + [u'[]-[]-[03]', None, None, None, None, None, None, u'dd', 3, 33]
        """
        res = mldb.query("""
        SELECT * FROM
            (SELECT name, n as s1_n, 1 as s1_1 FROM t1) AS s1
            FULL JOIN
            (SELECT name, n as s2_n, 2 as s2_2 FROM t2) AS s2
            ON s1.name = s2.name
            FULL JOIN
            (SELECT name, n as s3_n, 3 as s3_2 FROM t3) AS s3
            ON s2.name = s3.name
        """)
        pprint(res)
        self.assertTableResultEquals(res,
            [
                [u'_rowName', u's1.name', u's1.s1_1', u's1.s1_n', u's2.name', u's2.s2_2', u's2.s2_n', u's3.name', u's3.s3_2', u's3.s3_n'] ,
                [u'[01]-[01]-[01]', u'bb', 1, 11, u'bb', 2, 12, u'bb', 3, 13] ,
                [u'[]-[02]-[02]', None, None, None, u'cc', 2, 22, u'cc', 3, 23] ,
                [u'[]-[]-[03]', None, None, None, None, None, None, u'dd', 3, 33] ,
                [u'[]-[03]-[]', None, None, None, u'ee', 2, 42, None, None, None]
            ]
        )

    def test_join_with_null_condition(self):

        res = mldb.query("""
        select * from x left join y on x.x1 = y.y1 and x.x2 is not null
        """)

        self.assertTableResultEquals(res,
            [
                [u'_rowName', u'x.x1', u'x.x2', u'y.y1', u'y.y2'] ,
                [u'[03]-[]', 3, None, None, None] ,
                [u'[05]-[]', 5, None, None, None] ,
                [u'[01]-[01]', 1, 11, 1, 111] ,
                [u'[02]-[02]', 2, 22, 2, 222] ,
                [u'[04]-[04]', 4, 44, 4, None]
            ]
        )

        res = mldb.query("""
        select * from x left join y left join x as xx
        """)
        # number of rows
        self.assertEqual(len(res), 5 * 4 * 5 + 1)
        # number of columns
        self.assertEqual(len(res[0]), 2 + 2 + 2 + 1)

        res = mldb.query("""
        select * from x left join y on (x.x1 = y.y1) left join x as xx
        """)
        # number of rows
        self.assertEqual(len(res), 5 * 5 + 1)
        # number of columns
        self.assertEqual(len(res[0]), 2 + 2 + 2 + 1)

    # MDLB-1602
    def test_left_join_with_and(self):
        res1 = mldb.query("""
        select * from x
        left join y on (x.x1 = y.y1)
        left join z on (x.x1 = z.z1 and x.x2 = z.z2)
        order by rowName()
        """)
        pprint(res1)

        res2 = mldb.query("""
        select * from x
        left join y on (x.x1 = y.y1)
        left join z on (x.x1 + x.x2 = z.z1 + z.z2)
        order by rowName()
        """)
        pprint(res2)
        self.assertEquals(res1, res2)

    # MDLB-1602
    def test_right_join_with_and(self):
        """
        Note the difference in naming the last row.
        This is tracked by MLDBFB-536.
        """
        res = mldb.query("""
        select * from x
        right join y on (x.x1 = y.y1)
        right join z on (x.x1 = z.z1 and x.x2 = z.z2)
        order by rowName()
        """)
        pprint(res)
        self.assertTableResultEquals(res,
            [
                [u'_rowName', u'x.x1', u'x.x2', u'y.y1', u'y.y2', u'z.z1', u'z.z2'] ,
                [u'[01]-[01]-[01]', 1, 11, 1, 111, 1, 11] ,
                [u'[02]-[02]-[02]', 2, 22, 2, 222, 2, 22] ,
                [u'[]-[]-[03]', None, None, None, None, 3, 33]
            ]
        )

        res = mldb.query("""
        select * from x
        right join y on (x.x1 = y.y1)
        right join z on (x.x1 + x.x2 = z.z1 + z.z2)
        order by rowName()
        """)
        pprint(res)
        self.assertTableResultEquals(res,
            [
                [u'_rowName', u'x.x1', u'x.x2', u'y.y1', u'y.y2', u'z.z1', u'z.z2'] ,
                [u'[01]-[01]-[01]', 1, 11, 1, 111, 1, 11] ,
                [u'[02]-[02]-[02]', 2, 22, 2, 222, 2, 22] ,
                [u'[]-[]-[03]', None, None, None, None, 3, 33]
            ]
        )

    def test_row_naming_in_two_executors(self):

        res1 = mldb.query("""
        select * from x
        right join y on (x.x1 = y.y1)
        right join z on (x.x1 = z.z1 and x.x2 = z.z2)
        order by rowName()
        """)
        pprint(res1)
        res2 = mldb.query("""
        select * from x
        right join y on (x.x1 = y.y1)
        right join z on (x.x1 + x.x2 = z.z1 + z.z2)
        order by rowName()
        """)
        pprint(res2)
        # the first join is processed by the pipeline executor
        # the second join is processed by the batch executor
        # note the difference in naming the last row
        self.assertEquals(res1, res2)


    def test_worst_case_equi_join(self):
        """
        When an equijoin is done on a constant value than
        the cross product of the table is expected
        """
        ds = mldb.create_dataset({ "id": "LEFT_TBL", "type": "tabular" })
        ds.record_row("01",[["y1", 1, 0], ["y2", 111, 0]])
        ds.record_row("02",[["y1", 1, 0], ["y2", 111, 0]])
        ds.record_row("03",[["y1", 1, 0], ["y2", 111, 0]])
        ds.commit()

        ds = mldb.create_dataset({ "id": "RIGHT_TBL", "type": "tabular" })
        ds.record_row("01",[["z1", 1, 0], ["z2", 111, 0]])
        ds.record_row("02",[["z1", 1, 0], ["z2", 111, 0]])
        ds.record_row("03",[["z1", 1, 0], ["z2", 111, 0]])
        ds.commit()

        res1 = mldb.query("""
        select * from LEFT_TBL join RIGHT_TBL on LEFT_TBL.y1 = RIGHT_TBL.z1 order by rowName()
        """)
        pprint(res1)
        res2 = mldb.query("""
        select * from LEFT_TBL join RIGHT_TBL on LEFT_TBL.y1 = RIGHT_TBL.z1 AND LEFT_TBL.y2 = RIGHT_TBL.z2 order by rowName()
        """)
        pprint(res2)
        # the first join is processed by the pipeline executor
        # the second join is processed by the batch executor
        # note the difference in naming the last row
        self.assertEquals(res1, res2)

    def test_outer_join_with_pipeline_executor(self):
        # res = mldb.query("""
        # select * from x
        # right join z on (x.x1 = z.z1 and x.x2 = z.z2)
        # order by rowName()
        # """)
        # pprint(res)
        # self.assertTableResultEquals(res,
        #     [
        #         [u'_rowName', u'x.x1', u'x.x2', u'z.z1', u'z.z2'] ,
        #         [u'[01]-[01]', 1, 11, 1, 11] ,
        #         [u'[02]-[02]', 2, 22, 2, 22] ,
        #         [u'[]-[03]', None, None, 3, 33]
        #     ]
        # )

        res = mldb.query("""
        select * from z
        left join x on (x.x1 = z.z1 and x.x2 = z.z2)
        order by rowName()
        """)
        pprint(res)
        self.assertTableResultEquals(res,
            [
                [u'_rowName', u'x.x1', u'x.x2', u'z.z1', u'z.z2'] ,
                [u'[01]-[01]', 1, 11, 1, 11] ,
                [u'[02]-[02]', 2, 22, 2, 22] ,
                [u'[03]-[]', None, None, 3, 33]
            ]
        )

    def test_equijoin_with_larger_table(self):
        """ Test that both executors return the same number of rows """
        rowCount = 1000
        randomMax = 100

        ds = mldb.create_dataset({ "id": "join_left", "type": "sparse.mutable" })
        for index, row in enumerate(range(1, rowCount)):
            r1 = random.randint(1, randomMax)
            r2 = random.randint(1, randomMax)
            ds.record_row("row"+str(index),[["a", r1, 0], ["b", r2, 0], ["c", 1, 0]])
            ds.commit()

        ds = mldb.create_dataset({ "id": "join_right", "type": "sparse.mutable" })
        for index, row in enumerate(range(1, rowCount)):
            r1 = random.randint(1, randomMax)
            r2 = random.randint(1, randomMax)
            ds.record_row("row"+str(index),[["a", r1, 0], ["b", r2, 0], ["c", 1, 0]])
            ds.commit()

        res_std_exec = mldb.query("""
        SELECT count(*) AS count FROM join_left
        JOIN join_right
        ON join_left.a = join_right.b
        """)

        self.assertAlmostEqual(res_std_exec[1][1],
                               rowCount * rowCount / randomMax, delta = rowCount * rowCount / (randomMax * 10))

        mldb.log(res_std_exec)

        res_pipe_exec = mldb.query( """
        SELECT count(*) AS count FROM join_left
        JOIN join_right
        ON join_left.a = join_right.b
        AND join_left.c = join_right.c
        """)

        mldb.log(len(res_pipe_exec))
        self.assertAlmostEqual(res_pipe_exec[1][1],
                               rowCount * rowCount / randomMax, delta = rowCount * rowCount / (randomMax * 10))

    def test_join_on_false(self):
        ds = mldb.create_dataset({'id' : 'ds1', 'type' : 'sparse.mutable'})
        ds.record_row('row1', [['colA', 1, 0]])
        ds.commit()
        ds = mldb.create_dataset({'id' : 'ds2', 'type' : 'sparse.mutable'})
        ds.record_row('row2', [['colB', 1, 0]])
        ds.commit()

        expected = [["_rowName", "s1.colA", "s2.colB"],
                    [ "[row1]-[]", 1, None],
                    [ "[]-[row2]", None, 1]]
        res = mldb.query("""
            SELECT * FROM (SELECT * FROM ds1) AS s1
            OUTER JOIN (SELECT * FROM ds2) AS s2 ON false
        """)
        self.assertTableResultEquals(res, expected)

        res = mldb.query("""
            SELECT * FROM (SELECT * FROM ds1) AS s1
            OUTER JOIN (SELECT * FROM ds2) AS s2 ON s1.rowName() = 'wwwwwwwww'
        """)
        self.assertTableResultEquals(res, expected)

        res = mldb.query("""
            SELECT * FROM (SELECT * FROM ds1) AS s1
            OUTER JOIN (SELECT * FROM ds2) AS s2 ON s1.rowName() = 'wwwwwwwww'
            AND s2.rowName() = 'wwwwwwwww'
        """)
        self.assertTableResultEquals(res, expected)


mldb.run_tests()
